From 87eb749f7779583ce9d5d94aede1def427cc2897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bryan=E2=84=A2?= <61433408+brycahta@users.noreply.github.com> Date: Thu, 26 Aug 2021 17:14:01 -0500 Subject: [PATCH] separate release and build-and-test workflows (#139) --- .github/workflows/build-and-test.yaml | 83 +++++++++++ .github/workflows/ci.yaml | 195 -------------------------- .github/workflows/release.yaml | 123 ++++++++++++++++ 3 files changed, 206 insertions(+), 195 deletions(-) create mode 100644 .github/workflows/build-and-test.yaml delete mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml new file mode 100644 index 0000000..39a65b1 --- /dev/null +++ b/.github/workflows/build-and-test.yaml @@ -0,0 +1,83 @@ +name: Build and Test + +on: + push: + tags-ignore: + - "v*.*.*" + pull_request: + workflow_dispatch: + # Run M-F at 5AM CDT + schedule: + - cron: '0 10 * * 1-5' + +env: + DEFAULT_GO_VERSION: ^1.17 + DEFAULT_PY_VERSION: "3.9" + IS_PUSH: ${{ github.event_name == 'push' }} + +jobs: + buildAndTest: + name: Build and Test + runs-on: ubuntu-20.04 + steps: + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ${{ env.DEFAULT_GO_VERSION }} + + - name: Set up Python ${{ env.DEFAULT_PY_VERSION }} + uses: actions/setup-python@v2 + with: + python-version: ${{ env.DEFAULT_PY_VERSION }} + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build + run: make build + + - name: Unit Tests + run: make unit-test + + - name: Lints + run: make spellcheck shellcheck + + - name: Go Report Card Tests + run: make go-report-card-test + + - name: Readme Length Validator + run: make validate-readme + + - name: Brew Sync Dry run + run: make homebrew-sync-dry-run + + - name: License Test + if: ${{ env.IS_PUSH == true }} + run: make license-test + + - name: E2E Tests + run: make e2e-test + + - name: Mock IP Count Test + run: make helm-mock-ip-count-test + + - name: Build Release Assets + run: make build-release-assets + + - name: Build Docker Images Linux + run: make build-docker-images-linux + + buildWindows: + name: Build Docker Images Windows + runs-on: windows-2019 + steps: + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ${{ env.DEFAULT_GO_VERSION }} + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build Docker Images Windows + run: choco install make && RefreshEnv.cmd && make build-docker-images-windows \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 551e968..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,195 +0,0 @@ -name: EC2 Metadata Mock CI and Release - -on: - push: - pull_request: - workflow_dispatch: - # Run M-F at 5AM CDT - schedule: - - cron: '0 10 * * 1-5' - -env: - DEFAULT_GO_VERSION: ^1.17 - DEFAULT_PY_VERSION: "3.9" - IS_PUSH: ${{ github.event_name == 'push' }} - GITHUB_USERNAME: ${{ secrets.EC2_BOT_GITHUB_USERNAME }} - GITHUB_TOKEN: ${{ secrets.EC2_BOT_GITHUB_TOKEN }} - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - -jobs: - - buildAndTest: - # Not necessary to run buildAndTest targets during release - if: ${{ !contains(github.ref, 'refs/tags/') }} - name: Build and Test - runs-on: ubuntu-20.04 - steps: - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - - - name: Set up Python ${{ env.DEFAULT_PY_VERSION }} - uses: actions/setup-python@v2 - with: - python-version: ${{ env.DEFAULT_PY_VERSION }} - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Build - run: make build - - - name: Unit Tests - run: make unit-test - - - name: Lints - run: make spellcheck shellcheck - - - name: Go Report Card Tests - run: make go-report-card-test - - - name: Readme Length Validator - run: make validate-readme - - - name: Brew Sync Dry run - run: make homebrew-sync-dry-run - - - name: License Test - if: ${{ env.IS_PUSH == true }} - run: make license-test - - - name: E2E Tests - run: make e2e-test - - - name: Mock IP Count Test - run: make helm-mock-ip-count-test - - - name: Build Release Assets - run: make build-release-assets - - - name: Build Docker Images Linux - run: make build-docker-images-linux - - buildWindows: - # Not necessary to run build targets during release - if: ${{ !contains(github.ref, 'refs/tags/') }} - name: Build Docker Images Windows - runs-on: windows-2019 - steps: - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Build Docker Images Windows - run: choco install make && RefreshEnv.cmd && make build-docker-images-windows - - release: - name: Release - runs-on: ubuntu-20.04 - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - steps: - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Validate Release Version - run: make validate-release-version - - - name: Github Release - run: make release-github - - - name: Release Docker Linux - run: make release-docker-linux - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} - - releaseWindows: - name: Release Windows - runs-on: windows-2019 - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - steps: - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Release Windows Docker Image - run: choco install make && RefreshEnv.cmd && make release-docker-windows - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} - - postRelease: - name: Post Release - runs-on: ubuntu-20.04 - needs: [release, releaseWindows] - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - steps: - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Sync to Homebrew - run: make homebrew-sync - - - helmLint: - name: Helm Lint Test - runs-on: ubuntu-20.04 - needs: [release, releaseWindows] - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - steps: - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Helm Lint Test - run: make validate-release-version - - chartTests: - name: Helm Chart Tests - runs-on: ubuntu-20.04 - needs: [release, releaseWindows] - # Skip running this stage when updating release versions as part of release prep - # as the new Docker image wouldn't be available yet and previous commits should have already been tested. - # Since the release prep commit will be the release commit, always run this stage when a new tag is pushed, as part of a release. - if: ${{ !contains(github.event.head_commit.message, 'Skip Helm E2E Tests') || (github.event_name == 'push' && contains(github.ref, 'refs/tags/')) }} - strategy: - matrix: - k8sVersion: [1.16, 1.17, 1.18, 1.19, 1.20, 1.21] - steps: - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Helm Chart Tests - run: test/helm/chart-test.sh -i -k ${{ matrix.k8sVersion }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..05e6435 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,123 @@ +name: Release + +on: + push: + tags: + - "v*.*.*" + +permissions: + contents: write # required for uploading releases + +env: + DEFAULT_GO_VERSION: ^1.17 + DEFAULT_PY_VERSION: "3.9" + GITHUB_USERNAME: ${{ secrets.EC2_BOT_GITHUB_USERNAME }} + GITHUB_TOKEN: ${{ secrets.EC2_BOT_GITHUB_TOKEN }} + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + +jobs: + release: + name: Release + runs-on: ubuntu-20.04 + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + steps: + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ${{ env.DEFAULT_GO_VERSION }} + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Validate Release Version + run: make validate-release-version + + - name: Github Release + run: make release-github + + - name: Release Docker Linux + run: make release-docker-linux + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} + + releaseWindows: + name: Release Windows + runs-on: windows-2019 + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + steps: + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ${{ env.DEFAULT_GO_VERSION }} + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Release Windows Docker Image + run: choco install make && RefreshEnv.cmd && make release-docker-windows + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} + + postRelease: + name: Post Release + runs-on: ubuntu-20.04 + needs: [release, releaseWindows] + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + steps: + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ${{ env.DEFAULT_GO_VERSION }} + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Sync to Homebrew + run: make homebrew-sync + + + helmLint: + name: Helm Lint Test + runs-on: ubuntu-20.04 + needs: [release, releaseWindows] + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + steps: + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ${{ env.DEFAULT_GO_VERSION }} + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Helm Lint Test + run: make validate-release-version + + chartTests: + name: Helm Chart Tests + runs-on: ubuntu-20.04 + needs: [release, releaseWindows] + # Skip running this stage when updating release versions as part of release prep + # as the new Docker image wouldn't be available yet and previous commits should have already been tested. + # Since the release prep commit will be the release commit, always run this stage when a new tag is pushed, as part of a release. + if: ${{ !contains(github.event.head_commit.message, 'Skip Helm E2E Tests') || (github.event_name == 'push' && contains(github.ref, 'refs/tags/')) }} + strategy: + matrix: + k8sVersion: [1.16, 1.17, 1.18, 1.19, 1.20, 1.21] + steps: + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ${{ env.DEFAULT_GO_VERSION }} + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Helm Chart Tests + run: test/helm/chart-test.sh -i -k ${{ matrix.k8sVersion }} \ No newline at end of file