diff --git a/.github/workflows/build-excluded-packages.yml b/.github/workflows/build-excluded-packages.yml index f3461b629b..8a818ba74c 100644 --- a/.github/workflows/build-excluded-packages.yml +++ b/.github/workflows/build-excluded-packages.yml @@ -1,6 +1,6 @@ name: Check excluded packages -on: pull_request +on: workflow_call jobs: build: diff --git a/.github/workflows/e2e-tests-main-devnet.yml b/.github/workflows/e2e-tests-main-devnet.yml index 1858f21eae..e4711c6b03 100644 --- a/.github/workflows/e2e-tests-main-devnet.yml +++ b/.github/workflows/e2e-tests-main-devnet.yml @@ -13,16 +13,17 @@ on: - main jobs: - build-node: - name: Build binary artifact and docker image of the node + build-new-node: + name: Build node and runtime artifacts (PR version) + uses: Cardinal-Cryptography/aleph-node/.github/workflows/build-node-and-runtime.yml@main + with: + rust-toolchain-version: 'nightly-2021-10-24' + + + build-docker-not-cached: + needs: [build-new-node] + name: Build docker image of the node runs-on: ubuntu-latest - env: - RUST_TOOLCHAIN_VERSION: nightly-2021-10-24 - RUST_BACKTRACE: full - SCCACHE_VERSION: 0.2.13 - SCCACHE_CACHE_SIZE: 2G - SCCACHE_PATH: /home/runner/.cache/sccache - # SCCACHE_RECACHE: 1 # to clear cache uncomment this, let the workflow run once, then comment it out again steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.9.0 @@ -32,101 +33,35 @@ jobs: - name: Checkout Source code uses: actions/checkout@v2 - - name: Install sccache for ubuntu-latest - env: - LINK: https://github.com/mozilla/sccache/releases/download - run: | - SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl - mkdir -p $HOME/.local/bin - curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz - mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache - echo "$HOME/.local/bin" >> $GITHUB_PATH - - - name: Restore Cargo Cache - uses: actions/cache@v2 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - name: Install Rust Toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} - override: true - - - name: Install WASM target - run: rustup target add wasm32-unknown-unknown --toolchain "$RUST_TOOLCHAIN_VERSION" - - - name: Restore sccache - uses: actions/cache@v2 - continue-on-error: false - with: - path: ${{ env.SCCACHE_PATH }} - key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }} - - - name: Start sccache server - run: sccache --start-server - - - name: Build Binary - run: | - export RUSTC_WRAPPER=$HOME/.local/bin/sccache - cargo build --release - - - name: Build runtime - run: | - export RUSTC_WRAPPER=$HOME/.local/bin/sccache - cargo build --release -p aleph-runtime - - - name: Print sccache stats - run: sccache --show-stats - - - name: Stop sccache server - run: sccache --stop-server || true - - - name: Upload binary - uses: actions/upload-artifact@v2 + - name: Download artifact + uses: actions/download-artifact@v2 with: name: aleph-node - path: target/release/aleph-node - if-no-files-found: error - retention-days: 7 - - - name: Upload runtime - uses: actions/upload-artifact@v2 - with: - name: aleph-runtime - path: target/release/wbuild/aleph-runtime/aleph_runtime.compact.wasm - if-no-files-found: error - retention-days: 7 + path: target/release/ - name: Build docker image id: build-image run: | + ls -al target/release/aleph-node + chmod +x target/release/aleph-node + sha256sum target/release/aleph-node docker build --tag aleph-node:latest -f ./docker/Dockerfile . docker save -o aleph-node.tar aleph-node:latest + docker history --no-trunc aleph-node:latest - name: Upload docker image uses: actions/upload-artifact@v2 with: - name: aleph-node + name: aleph-docker path: aleph-node.tar if-no-files-found: error retention-days: 7 - check-determinism: - needs: [build-node] - name: Verify runtime build determinism + build-docker-cached: + needs: [build-new-node] + name: Build docker image of the node runs-on: ubuntu-latest - env: - RUST_TOOLCHAIN_VERSION: nightly-2021-10-24 - RUST_BACKTRACE: full steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.9.0 @@ -136,183 +71,36 @@ jobs: - name: Checkout Source code uses: actions/checkout@v2 - - name: Install Rust Toolchain - uses: actions-rs/toolchain@v1 + - name: Restore Cargo Cache + uses: actions/cache@v2 with: - profile: minimal - toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} - override: true - - - name: Install WASM target - run: rustup target add wasm32-unknown-unknown --toolchain "$RUST_TOOLCHAIN_VERSION" + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Download artifact uses: actions/download-artifact@v2 with: - name: aleph-runtime - - - name: Build runtime and compare checksum with artifact - env: - ARTIFACT: aleph_runtime.compact.wasm - TARGET_DIR: target/release/wbuild/aleph-runtime - run: | - mkdir -p "$TARGET_DIR" - mv "$ARTIFACT" "$TARGET_DIR" - sha256sum "$TARGET_DIR/$ARTIFACT" > checksum.sha256 - cargo clean - cargo build --release -p aleph-runtime - sha256sum -c checksum.sha256 - - - build-test-client: - name: Build e2e test client suite - runs-on: ubuntu-latest - env: - RUST_TOOLCHAIN_VERSION: nightly-2021-10-24 - RUST_BACKTRACE: full - steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.9.0 - with: - access_token: ${{ github.token }} - - - name: Checkout Source code - uses: actions/checkout@v2 - - - name: Install Rust Toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} - override: true + name: aleph-node + path: target/release/ - - name: Build binary and docker image + - name: Build docker image + id: build-image run: | - cd e2e-tests/ - cargo build --release - docker build --tag aleph-e2e-client:latest -f Dockerfile . - docker save -o aleph-e2e-client.tar aleph-e2e-client:latest + ls -al target/release/aleph-node + sha256sum target/release/aleph-node + docker build --tag aleph-node:latest -f ./docker/Dockerfile . + docker save -o aleph-node.tar aleph-node:latest + docker history --no-trunc aleph-node:latest - - name: Upload Artifact + - name: Upload docker image uses: actions/upload-artifact@v2 with: - name: aleph-e2e-client - path: e2e-tests/aleph-e2e-client.tar + name: aleph-docker-cached + path: aleph-node.tar if-no-files-found: error retention-days: 7 - - - run-e2e-tests: - needs: [build-node, build-test-client] - name: Run e2e tests suite - runs-on: ubuntu-latest - steps: - - name: GIT | Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.9.0 - with: - access_token: ${{ github.token }} - - - name: GIT | Checkout Source code - uses: actions/checkout@v2 - - - name: Download artifact with docker image - uses: actions/download-artifact@v2 - with: - name: aleph-node - - - name: Load node docker image - shell: bash - run: docker load -i aleph-node.tar - - - name: Run consensus party - run: ./.github/scripts/run_consensus.sh - - - name: Display bootnode logs - run: docker logs damian --follow & - - - name: Download artifact with the test suite image - uses: actions/download-artifact@v2 - with: - name: aleph-e2e-client - - - name: Load test suite docker image - shell: bash - run: docker load -i aleph-e2e-client.tar - - - name: Run e2e test suite - shell: bash - timeout-minutes: 10 - run: | - ./.github/scripts/run_e2e_tests.sh - - - push-image: - needs: [run-e2e-tests] - name: Push node image to the ECR repository - runs-on: ubuntu-latest - steps: - - name: GIT | Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.9.0 - with: - access_token: ${{ github.token }} - - - name: GIT | Checkout Source code - if: github.event_name == 'push' - uses: actions/checkout@v2 - - - name: Download artifact with docker image - if: github.event_name == 'push' - uses: actions/download-artifact@v2 - with: - name: aleph-node - - - name: Load node docker image - if: github.event_name == 'push' - shell: bash - run: docker load -i aleph-node.tar - - - name: Configure AWS credentials - if: github.event_name == 'push' - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }} - aws-region: eu-central-1 - - - name: Login to Public Amazon ECR - if: github.event_name == 'push' - id: login-public-ecr - uses: docker/login-action@v1 - with: - registry: public.ecr.aws - username: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }} - password: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }} - env: - AWS_REGION: us-east-1 - - - name: GIT | Get branch info & current commit sha. - id: vars - shell: bash - run: | - echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})" - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - - name: Push aleph-node Current Image to Public ECR - if: github.event_name == 'push' - env: - CURRENT_IMAGE: aleph-node:latest - ECR_PUSH_IMAGE: public.ecr.aws/p6e8q1z1/aleph-node:${{ steps.vars.outputs.sha_short }} - run: | - docker tag ${{ env.CURRENT_IMAGE }} ${{ env.ECR_PUSH_IMAGE }} - docker push ${{ env.ECR_PUSH_IMAGE }} - - - name: Send Slack Notification - if: github.event_name == 'push' - uses: rtCamp/action-slack-notify@v2 - continue-on-error: true - env: - SLACK_COLOR: ${{ job.status }} - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - SLACK_USERNAME: GithubActions - SLACK_TITLE: e2e tests job has finished - MSG_MINIMAL: actions url diff --git a/.github/workflows/post-dod-checklist.yml b/.github/workflows/post-dod-checklist.yml index 2935f3d3db..667c3eb6a7 100644 --- a/.github/workflows/post-dod-checklist.yml +++ b/.github/workflows/post-dod-checklist.yml @@ -1,5 +1,5 @@ name: Post DoD checklist -on: [pull_request_target] +on: workflow_call jobs: run: runs-on: ubuntu-latest diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index f5b67797e9..df49ddc379 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -1,6 +1,6 @@ name: unit-tests -on: pull_request +on: workflow_call jobs: check-test-and-lint: