From bef7cc24c76a36495c31a69330e345c406cffe10 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Mon, 16 Aug 2021 10:11:44 -0500 Subject: [PATCH] chore: isolated test worksflows for individual job runs (#1730) Co-authored-by: Arijit Das --- .github/workflows/code-cov.yml | 55 +++++++ .github/workflows/docker-grandpa.yml | 29 ++++ .github/workflows/docker-js.yml | 29 ++++ .github/workflows/docker-rpc.yml | 29 ++++ .github/workflows/docker-stable.yml | 29 ++++ .github/workflows/docker-stress.yml | 29 ++++ .github/workflows/tests.yml | 230 --------------------------- .github/workflows/unit-tests.yml | 63 ++++++++ 8 files changed, 263 insertions(+), 230 deletions(-) create mode 100644 .github/workflows/code-cov.yml create mode 100644 .github/workflows/docker-grandpa.yml create mode 100644 .github/workflows/docker-js.yml create mode 100644 .github/workflows/docker-rpc.yml create mode 100644 .github/workflows/docker-stable.yml create mode 100644 .github/workflows/docker-stress.yml delete mode 100644 .github/workflows/tests.yml create mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/code-cov.yml b/.github/workflows/code-cov.yml new file mode 100644 index 0000000000..db9c63be88 --- /dev/null +++ b/.github/workflows/code-cov.yml @@ -0,0 +1,55 @@ +on: [pull_request] +name: code-cov +env: + GO111MODULE: on + +jobs: + publish-code-coverage: + strategy: + matrix: + go-version: [1.15.x] + runs-on: ubuntu-latest + steps: + - id: go-cache-paths + run: | + echo "::set-output name=go-build::$(go env GOCACHE)" + echo "::set-output name=go-mod::$(go env GOMODCACHE)" + - uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + - uses: actions/checkout@v2 + + # cache go build cache + - name: Cache go modules + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ runner.os }}-go-build + + # cache go mod cache + - name: Cache go modules + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ runner.os }}-go-mod + + - name: Install Subkey + run: | + wget -P $HOME/.local/bin/ https://chainbridge.ams3.digitaloceanspaces.com/subkey-v2.0.0 + mv $HOME/.local/bin/subkey-v2.0.0 $HOME/.local/bin/subkey + chmod +x $HOME/.local/bin/subkey + echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Generate coverage report + run: | + go test ./... -short -coverprofile=coverage.out -covermode=atomic -timeout=20m + - uses: codecov/codecov-action@v1 + with: + if_ci_failed: success + informational: true + files: ./coverage.out + flags: unit-tests + name: coverage + verbose: true \ No newline at end of file diff --git a/.github/workflows/docker-grandpa.yml b/.github/workflows/docker-grandpa.yml new file mode 100644 index 0000000000..c1a0a0ff07 --- /dev/null +++ b/.github/workflows/docker-grandpa.yml @@ -0,0 +1,29 @@ +on: [pull_request] +name: docker-grandpa +env: + GO111MODULE: on + +jobs: + docker-grandpa-tests: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Build + id: docker_build + uses: docker/build-push-action@v2 + with: + load: true + file: ./Dockerfile + platforms: linux/amd64 + push: false + tags: chainsafe/gossamer:test + - + name: Run grandpa + run: | + docker run chainsafe/gossamer:test sh -c "make it-grandpa" \ No newline at end of file diff --git a/.github/workflows/docker-js.yml b/.github/workflows/docker-js.yml new file mode 100644 index 0000000000..ff733b0a95 --- /dev/null +++ b/.github/workflows/docker-js.yml @@ -0,0 +1,29 @@ +on: [pull_request] +name: docker-js +env: + GO111MODULE: on + +jobs: + docker-polkadotjs-tests: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Build + id: docker_build + uses: docker/build-push-action@v2 + with: + load: true + file: ./Dockerfile + platforms: linux/amd64 + push: false + tags: chainsafe/gossamer:test + - + name: Run polkadotjs tests + run: | + docker run chainsafe/gossamer:test sh -c "make it-polkadotjs" \ No newline at end of file diff --git a/.github/workflows/docker-rpc.yml b/.github/workflows/docker-rpc.yml new file mode 100644 index 0000000000..a09d6c7b9c --- /dev/null +++ b/.github/workflows/docker-rpc.yml @@ -0,0 +1,29 @@ +on: [pull_request] +name: docker-rpc +env: + GO111MODULE: on + +jobs: + docker-rpc-tests: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Build + id: docker_build + uses: docker/build-push-action@v2 + with: + load: true + file: ./Dockerfile + platforms: linux/amd64 + push: false + tags: chainsafe/gossamer:test + - + name: Run rpc tests + run: | + docker run chainsafe/gossamer:test sh -c "make it-rpc" \ No newline at end of file diff --git a/.github/workflows/docker-stable.yml b/.github/workflows/docker-stable.yml new file mode 100644 index 0000000000..4e9af6c57a --- /dev/null +++ b/.github/workflows/docker-stable.yml @@ -0,0 +1,29 @@ +on: [pull_request] +name: docker-stable +env: + GO111MODULE: on + +jobs: + docker-stable-tests: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Build + id: docker_build + uses: docker/build-push-action@v2 + with: + load: true + file: ./Dockerfile + platforms: linux/amd64 + push: false + tags: chainsafe/gossamer:test + - + name: Run stable tests + run: | + docker run chainsafe/gossamer:test sh -c "make it-stable" \ No newline at end of file diff --git a/.github/workflows/docker-stress.yml b/.github/workflows/docker-stress.yml new file mode 100644 index 0000000000..64c6d13196 --- /dev/null +++ b/.github/workflows/docker-stress.yml @@ -0,0 +1,29 @@ +on: [pull_request] +name: docker-stress +env: + GO111MODULE: on + +jobs: + docker-stress-tests: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Build + id: docker_build + uses: docker/build-push-action@v2 + with: + load: true + file: ./Dockerfile + platforms: linux/amd64 + push: false + tags: chainsafe/gossamer:test + - + name: Run stress + run: | + docker run chainsafe/gossamer:test sh -c "make it-stress" \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 11185af6d0..0000000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,230 +0,0 @@ -on: [pull_request] -name: tests -env: - GO111MODULE: on - -jobs: - unit-tests: - strategy: - matrix: - go-version: [1.15.x] - platform: [macos-latest, ubuntu-latest] - runs-on: ${{ matrix.platform }} - steps: - - id: go-cache-paths - run: | - echo "::set-output name=go-build::$(go env GOCACHE)" - echo "::set-output name=go-mod::$(go env GOMODCACHE)" - - - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - uses: actions/checkout@v2 - - # cache go build cache - - name: Cache go modules - uses: actions/cache@v2 - with: - path: ${{ steps.go-cache-paths.outputs.go-build }} - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-go-build - - # cache go mod cache - - name: Cache go modules - uses: actions/cache@v2 - with: - path: ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-go-mod - - - name: Install Subkey - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - wget -P $HOME/.local/bin/ https://chainbridge.ams3.digitaloceanspaces.com/subkey-v2.0.0 - mv $HOME/.local/bin/subkey-v2.0.0 $HOME/.local/bin/subkey - elif [ "$RUNNER_OS" == "macOS" ]; then - wget -P $HOME/.local/bin/ https://chainbridge.ams3.digitaloceanspaces.com/subkey-v2.0.0-macos - mv $HOME/.local/bin/subkey-v2.0.0-macos $HOME/.local/bin/subkey - else - echo "Subkey for $RUNNER_OS is not supported" - exit 1 - fi - - chmod +x $HOME/.local/bin/subkey - echo "$HOME/.local/bin" >> $GITHUB_PATH - - - name: Run unit tests - run: go test -short ./... -timeout=30m - - - name: Test State - Race - run: make test-state-race - - - name: Run build - run: make build - - publish-code-coverage: - runs-on: ubuntu-latest - steps: - - id: go-cache-paths - run: | - echo "::set-output name=go-build::$(go env GOCACHE)" - echo "::set-output name=go-mod::$(go env GOMODCACHE)" - - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - uses: actions/checkout@v2 - - # cache go build cache - - name: Cache go modules - uses: actions/cache@v2 - with: - path: ${{ steps.go-cache-paths.outputs.go-build }} - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-go-build - - # cache go mod cache - - name: Cache go modules - uses: actions/cache@v2 - with: - path: ${{ steps.go-cache-paths.outputs.go-mod }} - key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-go-mod - - - name: Install Subkey - run: | - wget -P $HOME/.local/bin/ https://chainbridge.ams3.digitaloceanspaces.com/subkey-v2.0.0 - mv $HOME/.local/bin/subkey-v2.0.0 $HOME/.local/bin/subkey - chmod +x $HOME/.local/bin/subkey - echo "$HOME/.local/bin" >> $GITHUB_PATH - - - name: Generate coverage report - run: | - go test ./... -short -coverprofile=coverage.out -covermode=atomic -timeout=20m - - uses: codecov/codecov-action@v1 - with: - if_ci_failed: success - informational: true - files: ./coverage.out - flags: unit-tests - name: coverage - verbose: true - - docker-stable-tests: - runs-on: ubuntu-latest - steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build - id: docker_build - uses: docker/build-push-action@v2 - with: - load: true - file: ./Dockerfile - platforms: linux/amd64 - push: false - tags: chainsafe/gossamer:test - - - name: Run stable tests - run: | - docker run chainsafe/gossamer:test sh -c "make it-stable" - - docker-rpc-tests: - runs-on: ubuntu-latest - steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build - id: docker_build - uses: docker/build-push-action@v2 - with: - load: true - file: ./Dockerfile - platforms: linux/amd64 - push: false - tags: chainsafe/gossamer:test - - - name: Run rpc tests - run: | - docker run chainsafe/gossamer:test sh -c "make it-rpc" - - docker-stress-tests: - runs-on: ubuntu-latest - steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build - id: docker_build - uses: docker/build-push-action@v2 - with: - load: true - file: ./Dockerfile - platforms: linux/amd64 - push: false - tags: chainsafe/gossamer:test - - - name: Run stress - run: | - docker run chainsafe/gossamer:test sh -c "make it-stress" - - docker-grandpa-tests: - runs-on: ubuntu-latest - steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build - id: docker_build - uses: docker/build-push-action@v2 - with: - load: true - file: ./Dockerfile - platforms: linux/amd64 - push: false - tags: chainsafe/gossamer:test - - - name: Run grandpa - run: | - docker run chainsafe/gossamer:test sh -c "make it-grandpa" - - docker-polkadotjs-tests: - runs-on: ubuntu-latest - steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build - id: docker_build - uses: docker/build-push-action@v2 - with: - load: true - file: ./Dockerfile - platforms: linux/amd64 - push: false - tags: chainsafe/gossamer:test - - - name: Run polkadotjs tests - run: | - docker run chainsafe/gossamer:test sh -c "make it-polkadotjs" diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000000..dd4b7c58e8 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,63 @@ +on: [pull_request] +name: unit-tests +env: + GO111MODULE: on + +jobs: + unit-tests: + strategy: + matrix: + go-version: [1.15.x] + platform: [macos-latest, ubuntu-latest] + runs-on: ${{ matrix.platform }} + steps: + - id: go-cache-paths + run: | + echo "::set-output name=go-build::$(go env GOCACHE)" + echo "::set-output name=go-mod::$(go env GOMODCACHE)" + + - uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + - uses: actions/checkout@v2 + + # cache go build cache + - name: Cache go modules + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ runner.os }}-go-build + + # cache go mod cache + - name: Cache go modules + uses: actions/cache@v2 + with: + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + restore-keys: ${{ runner.os }}-go-mod + + - name: Install Subkey + run: | + if [ "$RUNNER_OS" == "Linux" ]; then + wget -P $HOME/.local/bin/ https://chainbridge.ams3.digitaloceanspaces.com/subkey-v2.0.0 + mv $HOME/.local/bin/subkey-v2.0.0 $HOME/.local/bin/subkey + elif [ "$RUNNER_OS" == "macOS" ]; then + wget -P $HOME/.local/bin/ https://chainbridge.ams3.digitaloceanspaces.com/subkey-v2.0.0-macos + mv $HOME/.local/bin/subkey-v2.0.0-macos $HOME/.local/bin/subkey + else + echo "Subkey for $RUNNER_OS is not supported" + exit 1 + fi + + chmod +x $HOME/.local/bin/subkey + echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Run unit tests + run: go test -short ./... -timeout=30m + + - name: Test State - Race + run: make test-state-race + + - name: Run build + run: make build \ No newline at end of file