From 644bd0acec78c8f923da8ca22c9891c56e704c06 Mon Sep 17 00:00:00 2001 From: Levi Schoen Date: Wed, 30 Nov 2022 12:30:32 -0800 Subject: [PATCH] template and re-use ci workflows --- .github/workflows/ci-commit.yml | 16 +++++++ .github/workflows/ci-default.yml | 31 +++++++++++++ .github/workflows/ci-master.yml | 33 ++++++++++++++ .github/workflows/ci-pr.yml | 11 +++++ .github/workflows/ci.yml | 78 -------------------------------- .github/workflows/proto.yml | 3 +- 6 files changed, 92 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/ci-commit.yml create mode 100644 .github/workflows/ci-default.yml create mode 100644 .github/workflows/ci-master.yml create mode 100644 .github/workflows/ci-pr.yml delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci-commit.yml b/.github/workflows/ci-commit.yml new file mode 100644 index 00000000..02644bdb --- /dev/null +++ b/.github/workflows/ci-commit.yml @@ -0,0 +1,16 @@ +name: Continuous Integration (Commit) +on: + push: +# run per commit ci checks against this commit +jobs: + proto-lint: + uses: ./.github/workflows/proto.yml + golangci-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: golangci-lint + uses: reviewdog/action-golangci-lint@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review diff --git a/.github/workflows/ci-default.yml b/.github/workflows/ci-default.yml new file mode 100644 index 00000000..3aa9ea76 --- /dev/null +++ b/.github/workflows/ci-default.yml @@ -0,0 +1,31 @@ +name: Continuous Integration (Default Checks) + +on: + workflow_call: +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout repo from current commit + uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '1.18' + check-latest: true + cache: true + - name: build application + run: make build + test: + runs-on: ubuntu-latest + steps: + - name: checkout repo from current commit + uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '1.18' + check-latest: true + cache: true + - name: run unit tests + run: make test diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml new file mode 100644 index 00000000..c96152e2 --- /dev/null +++ b/.github/workflows/ci-master.yml @@ -0,0 +1,33 @@ +name: Continuous Integration (Kava Master) +on: + push: + # run CI on any push to the master branch + branches: + - master +jobs: + # run per commit ci checks against master branch + commit-checks: + uses: ./.github/workflows/ci-commit.yml + # run default ci checks against master branch + default-checks: + uses: ./.github/workflows/ci-default.yml + # build and upload versions of kava for use on internal infrastructure + # configurations for databases, cpu architectures and operating systems + publish-internal: + # only run if all checks pass + needs: [commit-checks, default-checks] + runs-on: ubuntu-latest + steps: + - name: set build tag + run: echo "BUILD_TAG=$(date +%s)-$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV + - name: build rocksdb dependency + run: bash ${GITHUB_WORKSPACE}/.github/scripts/install-rocksdb.sh + env: + ROCKSDB_VERSION: v7.7.3 + - name: Build and upload release artifacts + run: bash ${GITHUB_WORKSPACE}/.github/scripts/publish-internal-release-artifacts.sh + env: + BUILD_TAG: ${{ env.BUILD_TAG }} + AWS_REGION: us-east-1 + AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_KEY_SECRET }} diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml new file mode 100644 index 00000000..e947eff6 --- /dev/null +++ b/.github/workflows/ci-pr.yml @@ -0,0 +1,11 @@ +name: Continuous Integration (PR) +on: + pull_request: + # run CI on pull requests to master or a release branch + branches: + - master + - 'releases/**' +# run default ci checks against current PR +jobs: + default: + uses: ./.github/workflows/ci-default.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index b9662332..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Continuous Integration -on: - pull_request: - # run CI on pull requests to master or a release branch - branches: - - master - - 'releases/**' - push: - # run CI on any push to the master branch - branches: - - master -# concurrently lint, build, and run tests against kava based off current commit -jobs: - golangci-lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: golangci-lint - uses: reviewdog/action-golangci-lint@v1 - with: - github_token: ${{ secrets.github_token }} - reporter: github-pr-review - build: - runs-on: ubuntu-latest - steps: - - name: checkout repo from current commit - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: '1.18' - check-latest: true - cache: true - - name: build application - run: make build - test: - runs-on: ubuntu-latest - steps: - - name: checkout repo from current commit - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: '1.18' - check-latest: true - cache: true - - name: run unit tests - run: make test - # only run on merges to master - publish: - runs-on: ubuntu-latest - if: github.ref_name == 'master' - steps: - - name: checkout repo from current commit - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: '1.18' - check-latest: true - cache: true - - name: build application - run: make build - - name: run unit tests - run: make test - - name: set build tag - run: echo "BUILD_TAG=$(date +%s)-$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV - - name: build rocksdb dependency - run: bash ${GITHUB_WORKSPACE}/.github/scripts/install-rocksdb.sh - env: - ROCKSDB_VERSION: v7.7.3 - - name: Build and upload release artifacts - run: bash ${GITHUB_WORKSPACE}/.github/scripts/publish-internal-release-artifacts.sh - env: - BUILD_TAG: ${{ env.BUILD_TAG }} - AWS_REGION: us-east-1 - AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_KEY_SECRET }} diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 5bb91f52..9bdc2931 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -1,8 +1,7 @@ name: Protobuf Checks on: - push: - pull_request: + workflow_call: jobs: check-proto: