Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 1.13: Github actions and scripts. #1166

Merged
merged 8 commits into from
Oct 20, 2022
33 changes: 17 additions & 16 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ main, release/* ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main, release/* ]
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5
schedule:
- cron: '21 21 * * 3'
# Wednesdays at 21:23 (randomly chosen).
- cron: '23 21 * * 3'

# Set concurrency for this workflow to cancel in-progress jobs if retriggered.
# The github.ref is only available when triggered by a PR so fall back to github.run_id for other cases.
# The github.run_id is unique for each run, giving each such invocation it's own unique concurrency group.
# Basically, if you push to a PR branch, jobs that are still running for that PR will be cancelled.
# But jobs started because of a merge to main or a release tag push are not cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
analyze:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ on:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5

# Set concurrency for this workflow to cancel in-progress jobs if retriggered.
# The github.ref is only available when triggered by a PR so fall back to github.run_id for other cases.
# The github.run_id is unique for each run, giving each such invocation it's own unique concurrency group.
# Basically, if you push to a PR branch, jobs that are still running for that PR will be cancelled.
# But jobs started because of a merge to main or a release tag push are not cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
docker:
runs-on: ubuntu-latest
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
push:
branches:
- main

# concurrency is not defined in here because this job usually doesn't
# run long enough to need cancelling, and it's okay for it to run multiple
# times for the same PR.

jobs:
golangci:
name: golangci-lint
Expand All @@ -19,13 +24,19 @@ jobs:
**/**.go
go.mod
go.sum
.github/workflows/lint.yml
scripts/no-now-lint.sh
- uses: actions/setup-go@v3
if: env.GIT_DIFF
with:
go-version: 1.18
- uses: golangci/golangci-lint-action@v3.2.0
if: env.GIT_DIFF
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.48
args: --timeout 10m --out-${NO_FUTURE}format colored-line-number
github-token: ${{ secrets.github_token }}
- name: No Now Usage
if: env.GIT_DIFF
run: scripts/no-now-lint.sh
11 changes: 11 additions & 0 deletions .github/workflows/proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ on:
- "**/**.proto"
- "**/go.mod"
- ".github/workflows/proto.yml"
- "scripts/proto-update-check.sh"
- "scripts/proto-update-deps.sh"

# Set concurrency for this workflow to cancel in-progress jobs if retriggered.
# The github.ref is only available when triggered by a PR so fall back to github.run_id for other cases.
# The github.run_id is unique for each run, giving each such invocation it's own unique concurrency group.
# Basically, if you push to a PR branch, jobs that are still running for that PR will be cancelled.
# But jobs started because of a merge to main or a release tag push are not cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
buf_lint:
Expand Down
20 changes: 9 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@ on:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5

jobs:
# This action cleans up previously running instances of a workflow on the same branch. This accomplishes
# the task of automatically cancelling CI runs on pushes to the same branch, which is a common feature in
# most CI systems but currently not possible with GitHub actions.
cleanup-runs:
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@v0.3.3
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# Set concurrency for this workflow to cancel in-progress jobs if retriggered.
# The github.ref is only available when triggered by a PR so fall back to github.run_id for other cases.
# The github.run_id is unique for each run, giving each such invocation it's own unique concurrency group.
# Basically, if you push to a PR branch, jobs that are still running for that PR will be cancelled.
# But jobs started because of a merge to main or a release tag push are not cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
build_init:
runs-on: ubuntu-latest
name: Build Init
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/rosetta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ on:
branches:
- main

# Set concurrency for this workflow to cancel in-progress jobs if retriggered.
# The github.ref is only available when triggered by a PR so fall back to github.run_id for other cases.
# The github.run_id is unique for each run, giving each such invocation it's own unique concurrency group.
# Basically, if you push to a PR branch, jobs that are still running for that PR will be cancelled.
# But jobs started because of a merge to main or a release tag push are not cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
rosetta:
runs-on: ubuntu-latest
Expand Down
123 changes: 16 additions & 107 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ on:
env:
LD_LIBRARY_PATH: /usr/local/lib:/usr/local/lib/x86_64-linux-gnu

jobs:
cleanup-runs:
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@v0.3.3
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# Set concurrency for this workflow to cancel in-progress jobs if retriggered.
# The github.ref is only available when triggered by a PR so fall back to github.run_id for other cases.
# The github.run_id is unique for each run, giving each such invocation it's own unique concurrency group.
# Basically, if you push to a PR branch, jobs that are still running for that PR will be cancelled.
# But jobs started because of a merge to main or a release tag push are not cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
setup:
if: "!contains(github.event.head_commit.message, 'skip-sims')"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -56,17 +57,12 @@ jobs:
# * Go binary directory
# * Go module directory
# * Go build cache (Linux)
# * Go build cache (Mac)
go-cache-path: |
~/go/bin
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build

build-linux:
# Note: Can't use a matrix to combine build-linux and build-mac because they'd both have the same job id and that would cause
# problems below with the "needs" directive on the tests. Basically, as soon as the first one finished, the tests
# would kick off for both OSes even though one might not be ready yet.
needs: setup
if: needs.setup.outputs.should-run
runs-on: ubuntu-latest
Expand Down Expand Up @@ -128,98 +124,19 @@ jobs:
- name: Provenanced version
run: build/provenanced version --long

build-mac:
# Note: Can't use a matrix to combine build-linux and build-mac because they'd both have the same job id and that would cause
# problems below with the "needs" directive on the tests. Basically, as soon as the first one finished, the tests
# would kick off for both OSes even though one might not be ready yet.
needs: setup
if: needs.setup.outputs.should-run
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Output setup
run: |
echo " go-version: [${{ needs.setup.outputs.go-version }}]"
echo " should-run: [${{ needs.setup.outputs.should-run }}]"
echo " file-prefix: [${{ needs.setup.outputs.file-prefix }}]"
echo "db-cache-key-suffix: [${{ needs.setup.outputs.db-cache-key-suffix }}]"
echo " db-cache-path: [${{ needs.setup.outputs.db-cache-path }}]"
echo "go-cache-key-suffix: [${{ needs.setup.outputs.go-cache-key-suffix }}]"
echo " go-cache-path: [${{ needs.setup.outputs.go-cache-path }}]"
- uses: actions/cache@v3
name: Load db cache
id: db-cache-setup
with:
key: ${{ runner.os }}-${{ needs.setup.outputs.db-cache-key-suffix }}
path: ${{ needs.setup.outputs.db-cache-path }}
- uses: actions/cache@v3
name: Load go cache
id: go-cache-setup
with:
key: ${{ runner.os }}-${{ needs.setup.outputs.go-cache-key-suffix }}
path: ${{ needs.setup.outputs.go-cache-path }}
- name: Setup build environment
run: |
brew install cmake sqlite3
- name: Build cleveldb
if: steps.db-cache-setup.outputs.cache-hit != 'true'
# As of 2022-06-13 (it was a Monday), the macos-latest runners do not have the nproc command.
# But have 3 cores according to https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
# The linux runners have nproc, so we don't need to set the _JOBS in that job.
run: |
export CLEVELDB_JOBS=3
export CLEVELDB_DO_BUILD='true'
export CLEVELDB_DO_INSTALL='false'
export CLEVELDB_DO_CLEANUP='false'
make cleveldb
- name: Install cleveldb
run: |
export CLEVELDB_DO_BUILD='false'
export CLEVELDB_DO_INSTALL='true'
export CLEVELDB_SUDO='true'
export CLEVELDB_DO_CLEANUP='false'
make cleveldb
- uses: actions/setup-go@v3
with:
go-version: ${{ needs.setup.outputs.go-version }}
- name: Display go version
run: go version
- name: Install runsim
if: steps.go-cache-setup.outputs.cache-hit != 'true'
run: export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0
- name: Update provwasm contract
run: make download-smart-contracts
- name: Build provenanced
run: make build
- name: Provenanced version
run: build/provenanced version --long

runsim:
# These tests are the ones that use the runsim program (see sims.mk).
needs: [setup, build-linux]
if: needs.setup.outputs.should-run
strategy:
fail-fast: false
matrix:
# The test-sim-import-export test can take up to two hours.
# The test-sim-after-import test can take even longer.
# The test-sim-multi-seed-short test should take 30-40 minutes.
# TODO: Add the "after-import" test once it's fixed: https://github.com/provenance-io/provenance/issues/754
test: ["import-export", "multi-seed-short"]
db-backend: ["goleveldb", "cleveldb", "badgerdb"]
# Not putting "macos-latest" in this because:
# a) They take longer than on ubuntu to begin with.
# b) We're limited to 5 Mac runners at once so they get queued up, taking even longer to finish all of them.
# c) Most of the devs use a mac, so it's less likely that a Mac-specific bug goes unnoticed without these tests.
test: ["import-export", "multi-seed-short", "after-import"]
db-backend: ["goleveldb"]
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
name: Load db cache
with:
key: ${{ runner.os }}-${{ needs.setup.outputs.db-cache-key-suffix }}
path: ${{ needs.setup.outputs.db-cache-path }}
- uses: actions/cache@v3
name: Load go cache
with:
Expand All @@ -228,14 +145,6 @@ jobs:
- name: Define test-logs
id: test-logs
run: echo "::set-output name=test-logs::${{ needs.setup.outputs.file-prefix }}-${{ matrix.test }}-${{ matrix.db-backend }}-${{ matrix.os }}"
- name: Install cleveldb
if: matrix.db-backend == 'cleveldb'
run: |
export CLEVELDB_DO_BUILD='false'
export CLEVELDB_DO_INSTALL='true'
export CLEVELDB_SUDO='true'
export CLEVELDB_DO_CLEANUP='false'
make cleveldb
- uses: actions/setup-go@v3
with:
go-version: ${{ needs.setup.outputs.go-version }}
Expand Down Expand Up @@ -271,16 +180,16 @@ jobs:

go-test-multi-db:
# These are tests that use go test to run (see sims.mk), and that we want to test using different database backends.
needs: [setup, build-linux, build-mac]
needs: [setup, build-linux]
if: needs.setup.outputs.should-run
strategy:
fail-fast: false
matrix:
# The test-sim-simple test is pretty quick and should be able to identify glaring problems.
# The test-sim-benchmark is handy to have for each db type.
test: ["simple", "benchmark"]
db-backend: ["goleveldb", "cleveldb", "badgerdb"]
os: ["ubuntu-latest", "macos-latest"]
db-backend: ["goleveldb", "cleveldb"]
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -326,15 +235,15 @@ jobs:

go-test-single-db:
# These are tests that use go test to run (see sims.mk), and that we don't care about testing using different database backends.
needs: [setup, build-linux, build-mac]
needs: [setup, build-linux]
if: needs.setup.outputs.should-run
strategy:
fail-fast: false
matrix:
# The test-sim-nondeterminism test hard-codes the db backend to use memdb.
# The test-sim-benchmark-invariants test can use different db backends, but to save resources, is down here.
test: ["nondeterminism", "benchmark-invariants"]
os: ["ubuntu-latest", "macos-latest"]
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
20 changes: 8 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@ on:
branches:
- main

# Set concurrency for this workflow to cancel in-progress jobs if retriggered.
# The github.ref is only available when triggered by a PR so fall back to github.run_id for other cases.
# The github.run_id is unique for each run, giving each such invocation it's own unique concurrency group.
# Basically, if you push to a PR branch, jobs that are still running for that PR will be cancelled.
# But jobs started because of a merge to main or a release tag push are not cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
# This action cleans up previously running instances of a workflow on the same branch. This accomplishes
# the task of automatically cancelling CI runs on pushes to the same branch, which is a common feature in
# most CI systems but currently not possible with GitHub actions.
cleanup-runs:
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@v0.3.3
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"


setup-tests:
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ ifeq ($(WITH_BADGERDB),yes)
WITH_BADGERDB=true
endif

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null)
BRANCH_PRETTY := $(subst /,-,$(BRANCH))
TM_VERSION := $(shell $(GO) list -m github.com/tendermint/tendermint 2> /dev/null | sed 's:.* ::') # grab everything after the space in "github.com/tendermint/tendermint v0.34.7"
COMMIT := $(shell git log -1 --format='%h')
COMMIT := $(shell git log -1 --format='%h' 2> /dev/null)
# don't override user values
ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
Expand Down Expand Up @@ -334,6 +334,7 @@ go.sum: go.mod
lint:
$(GOLANGCI_LINT) run
find . -name '*.go' -type f -not -path "./vendor*" -not -path "./client/*" -not -path "*.git*" -not -path "*.pb.go" | xargs gofmt -d -s
scripts/no-now-lint.sh
$(GO) mod verify

clean:
Expand Down
Loading