feat: add redis-role label to redis replication #26
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
branches: | |
- master | |
push: | |
branches: | |
- master | |
permissions: | |
contents: read | |
env: | |
GOLANG_VERSION: 1.21 | |
APPLICATION_NAME: redis-operator | |
DockerImagName: docker.io/opstree/redis-operator | |
BuildDocs: true | |
AppVersion: "v0.15.2" | |
DOCKERFILE_PATH: "**/Dockerfile" | |
jobs: | |
gotest: | |
name: Go Test | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GOLANG_VERSION }} | |
- name: Install integration test dependencies | |
run: make integration-test-setup | |
- name: Run Go Tests with coverage | |
run: go test ./... -coverprofile=coverage.txt -covermode=atomic | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
file: ./coverage.txt | |
fail_ci_if_error: false | |
verbose: true | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GOLANG_VERSION }} | |
cache: false | |
- name: Run GolangCI-Lint | |
uses: golangci/golangci-lint-action@v5 | |
with: | |
version: v1.54.0 | |
container_quality_dockerfile_lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Execute dockerlinter | |
uses: hadolint/[email protected] | |
with: | |
dockerfile: Dockerfile | |
ignore: DL3007,DL3018 | |
build_go_binary: | |
needs: [lint] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: ["amd64", "arm64"] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Go Environment | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GOLANG_VERSION }} | |
- name: Set GOARCH | |
run: echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV | |
- name: Build Go Binary | |
run: go build -o ${{ github.workspace }}/${{ env.APPLICATION_NAME }} | |
- name: Archive Binary | |
run: | | |
mkdir -p ${{ github.workspace }}/compiled/${{ matrix.arch }} | |
zip ${{ github.workspace }}/compiled/${{ matrix.arch }}/${{ env.APPLICATION_NAME }}-${{ matrix.arch }}.zip ${{ github.workspace }}/${{ env.APPLICATION_NAME }} | |
build_scan_container_image: | |
needs: [container_quality_dockerfile_lint] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build multi-arch image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/arm64,linux/amd64 | |
push: false | |
tags: ${{ env.DockerImagName }}:latest | |
gosec_scan: | |
needs: [build_go_binary] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Gosec Scan | |
uses: securego/gosec@master | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GOSEC_OUTPUT: "junit-xml:/github/workspace/gosec-results.xml" | |
validate-yaml: | |
name: Validate YAML | |
runs-on: ubuntu-latest | |
needs: | |
- gotest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install yamllint | |
run: sudo apt-get install -y yamllint | |
- name: Lint YAML files | |
run: yamllint --strict ./tests/ | |
e2e-test: | |
needs: [validate-yaml] | |
name: ${{ matrix.testpath }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
testpath: | |
- ./tests/e2e-chainsaw/v1beta2/teardown/ | |
- ./tests/e2e-chainsaw/v1beta2/setup/ | |
- ./tests/e2e-chainsaw/v1beta2/hostnetwork/ | |
- ./tests/e2e-chainsaw/v1beta2/password/ | |
- ./tests/e2e-chainsaw/v1beta2/ha-setup/ | |
- ./tests/e2e-chainsaw/v1beta2/ha-failover/ | |
- ./tests/e2e-chainsaw/v1beta2/nodeport/ | |
- ./tests/e2e-chainsaw/v1beta2/pvc-name/ | |
- ./tests/e2e-chainsaw/v1beta2/keep-pvc/ | |
- ./tests/e2e-chainsaw/v1beta2/acl-user/ | |
- ./tests/e2e-chainsaw/v1beta2/scaling/ | |
- ./tests/e2e-chainsaw/v1beta2/ignore-annots/ | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build Dockerfile | |
run: docker build . --file Dockerfile --tag redis-operator:e2e | |
- name: Install chainsaw | |
uses: kyverno/chainsaw/.github/actions/[email protected] | |
with: | |
release: v0.1.7 | |
- name: Check install | |
run: chainsaw version | |
- name: Install kubectl | |
run: | | |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | |
chmod +x kubectl | |
sudo mv kubectl /usr/local/bin/ | |
# - name: Install Redis | |
# uses: shogo82148/actions-setup-redis@v1 | |
- name: Create k8s Kind Cluster | |
uses: helm/[email protected] | |
with: | |
config: tests/_config/kind-config.yaml | |
cluster_name: kind | |
- name: Load Docker image into Kind | |
run: | | |
kubectl cluster-info --context kind-kind | |
kind load docker-image redis-operator:e2e --name kind | |
- name: Install Redis Operator | |
run: | | |
make deploy IMG=redis-operator:e2e | |
- name: Wait for Redis Operator to be ready | |
run: | | |
kubectl wait --for=condition=available --timeout=300s deployment/redis-operator-redis-operator -n redis-operator-system | |
- name: Run chainsaw test | |
run: chainsaw test --test-dir ${{ matrix.testpath }} --config tests/_config/chainsaw-configuration.yaml |