diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 9b660d6d18..8257255df3 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -16,7 +16,7 @@ env: jobs: prepare: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest outputs: changes-target-branch: ${{ steps.changes.outputs.changes-target-branch }} changes-base-git-rev: ${{ steps.changes.outputs.changes-base-git-rev }} @@ -67,7 +67,7 @@ jobs: pattern: 'docker/ci\|scripts/dev_setup.sh' dev-setup-sh-test: - runs-on: ubuntu-20.04-xl + runs-on: ubuntu-latest timeout-minutes: 30 needs: prepare if: ${{ needs.prepare.outputs.test-dev-setup == 'true' }} @@ -77,7 +77,7 @@ jobs: target_os: [github] steps: - uses: actions/checkout@v2.4.0 - with: + with: ref: ${{ github.event.pull_request.head.sha }} - name: build image with dev-setup.sh run: docker build -f docker/ci/${{ matrix.target_os }}/Dockerfile -t diem/build_environment:test . @@ -88,7 +88,7 @@ jobs: github-token: ${{secrets.GITHUB_TOKEN}} lint: - runs-on: ubuntu-20.04-xl + runs-on: ubuntu-latest timeout-minutes: 30 needs: prepare if: ${{ needs.prepare.outputs.any-changes-founds == 'true' }} @@ -98,8 +98,6 @@ jobs: - "${{github.workspace}}:/opt/git/diem" steps: - uses: actions/checkout@v2.4.0 - with: - ref: ${{ github.event.pull_request.head.sha }} - uses: ./.github/actions/build-setup - uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c with: @@ -118,7 +116,7 @@ jobs: github-token: ${{secrets.GITHUB_TOKEN}} unit-test: - runs-on: ubuntu-20.04-xl + runs-on: ubuntu-latest timeout-minutes: 60 needs: prepare if: ${{ needs.prepare.outputs.test-rust == 'true' }} @@ -128,9 +126,6 @@ jobs: - "${{github.workspace}}:/opt/git/diem" steps: - uses: actions/checkout@v2.4.0 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 #get all the history!!! - uses: ./.github/actions/build-setup - uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c with: @@ -163,7 +158,7 @@ jobs: github-token: ${{secrets.GITHUB_TOKEN}} hardhat-tests: - runs-on: ubuntu-20.04-xl + runs-on: ubuntu-latest timeout-minutes: 20 needs: prepare if: ${{ needs.prepare.outputs.test-rust == 'true' }} @@ -173,8 +168,6 @@ jobs: - "${{github.workspace}}:/opt/git/diem" steps: - uses: actions/checkout@v2.4.0 - with: - ref: ${{ github.event.pull_request.head.sha }} - uses: ./.github/actions/build-setup - uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c - name: compile and install move-cli @@ -200,84 +193,78 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} - # Compile (but don't run) the benchmarks, to insulate against bit rot - build-benchmarks: - runs-on: ubuntu-20.04-xl - timeout-minutes: 30 - needs: prepare - if: ${{ needs.prepare.outputs.test-rust == 'true' }} - container: - image: ghcr.io/diem/diem_build_environment:${{ needs.prepare.outputs.changes-target-branch }} - volumes: - - "${{github.workspace}}:/opt/git/diem" - steps: - - uses: actions/checkout@v2.4.0 - with: - ref: ${{ github.event.pull_request.head.sha }} - - uses: ./.github/actions/build-setup - - uses: actions/cache@v2.1.6 - with: - path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache" - key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - restore-keys: "crates-${{ runner.os }}" - - name: build benchmarks - run: cargo x bench --no-run - - uses: ./.github/actions/build-teardown - - name: Early terminate workflow - if: ${{ failure() }} - uses: ./.github/actions/early-terminator - with: - github-token: ${{secrets.GITHUB_TOKEN}} + # # Compile (but don't run) the benchmarks, to insulate against bit rot + # build-benchmarks: + # runs-on: ubuntu-latest + # timeout-minutes: 30 + # needs: prepare + # if: ${{ needs.prepare.outputs.test-rust == 'true' }} + # container: + # image: ghcr.io/diem/diem_build_environment:${{ needs.prepare.outputs.changes-target-branch }} + # volumes: + # - "${{github.workspace}}:/opt/git/diem" + # steps: + # - uses: actions/checkout@v2.4.0 + # - uses: ./.github/actions/build-setup + # - uses: actions/cache@v2.1.6 + # with: + # path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache" + # key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + # restore-keys: "crates-${{ runner.os }}" + # - name: build benchmarks + # run: cargo x bench --no-run + # - uses: ./.github/actions/build-teardown + # - name: Early terminate workflow + # if: ${{ failure() }} + # uses: ./.github/actions/early-terminator + # with: + # github-token: ${{secrets.GITHUB_TOKEN}} - perf-benchmarks: - name: run-perf-benchmarks - runs-on: ubuntu-20.04-xl - timeout-minutes: 30 - needs: - - prepare - - build-benchmarks - env: - CRITERION_HOME: /tmp/benches - steps: - - uses: actions/checkout@v2.4.0 - with: - ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/cache@v2.1.6 - with: - path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache" - key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - restore-keys: "crates-${{ runner.os }}" - - name: Download the previous baseline - continue-on-error: true - uses: actions/download-artifact@v2 - with: - name: bench-baseline - - name: Run performance benchamrks - run: | - # Replace this with a cargo x bench - cargo bench --package language-benchmarks - - name: Archive criterion results - uses: actions/upload-artifact@v2 - with: - name: bench-baseline - retention-days: 5 - path: | - /tmp/benches - - name: Early terminate workflow - if: ${{ failure() }} - uses: ./.github/actions/early-terminator - with: - github-token: ${{secrets.GITHUB_TOKEN}} + # perf-benchmarks: + # name: run-perf-benchmarks + # runs-on: ubuntu-latest + # timeout-minutes: 30 + # needs: + # - prepare + # - build-benchmarks + # env: + # CRITERION_HOME: /tmp/benches + # steps: + # - uses: actions/checkout@v2.4.0 + # - uses: actions/cache@v2.1.6 + # with: + # path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache" + # key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + # restore-keys: "crates-${{ runner.os }}" + # - name: Download the previous baseline + # continue-on-error: true + # uses: actions/download-artifact@v2 + # with: + # name: bench-baseline + # - name: Run performance benchamrks + # run: | + # # Replace this with a cargo x bench + # cargo bench --package language-benchmarks + # - name: Archive criterion results + # uses: actions/upload-artifact@v2 + # with: + # name: bench-baseline + # retention-days: 5 + # path: | + # /tmp/benches + # - name: Early terminate workflow + # if: ${{ failure() }} + # uses: ./.github/actions/early-terminator + # with: + # github-token: ${{secrets.GITHUB_TOKEN}} build-move-analyzer-vscode-extension: name: Build VS Code extension for move-analyzer - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest needs: - prepare steps: - uses: actions/checkout@v2.4.0 - with: - ref: ${{ github.event.pull_request.head.sha }} - name: Use Node.js 14 uses: actions/setup-node@v2.4.0 with: diff --git a/devtools/x/src/lint/license.rs b/devtools/x/src/lint/license.rs index 3de932ffb1..7a590fec43 100644 --- a/devtools/x/src/lint/license.rs +++ b/devtools/x/src/lint/license.rs @@ -3,9 +3,28 @@ use x_lint::prelude::*; -static LICENSE_HEADER: &str = "Copyright (c) The Diem Core Contributors\n\ - SPDX-License-Identifier: Apache-2.0\n\ - "; +static ALLOWED_LICENSE_HEADERS: &[&str] = &[ + "Copyright (c) The Move Contributors\n\ + SPDX-License-Identifier: Apache-2.0\n\ + ", + "Copyright (c) The Diem Core Contributors\n\ + SPDX-License-Identifier: Apache-2.0\n\ + ", + "Copyright (c) The Move Contributors\n\ + Copyright (c) The Diem Core Contributors\n\ + SPDX-License-Identifier: Apache-2.0\n\ + ", +]; + +fn has_license<'a>(maybe_license: impl Iterator) -> bool { + let maybe = maybe_license.collect::>(); + for allowed in ALLOWED_LICENSE_HEADERS { + if allowed.lines().eq(maybe.clone().into_iter()) { + return true; + } + } + false +} #[derive(Copy, Clone, Debug)] pub(super) struct LicenseHeader; @@ -50,7 +69,7 @@ impl ContentLinter for LicenseHeader { .skip_while(|line| line.is_empty()) .take(2) .map(|s| s.trim_start_matches("// ")); - !LICENSE_HEADER.lines().eq(maybe_license) + !has_license(maybe_license) } FileType::Shell => { let maybe_license = content @@ -59,7 +78,7 @@ impl ContentLinter for LicenseHeader { .skip_while(|line| line.is_empty()) .take(2) .map(|s| s.trim_start_matches("# ")); - !LICENSE_HEADER.lines().eq(maybe_license) + !has_license(maybe_license) } }; diff --git a/scripts/check_pr.sh b/scripts/check_pr.sh new file mode 100755 index 0000000000..296b6ba106 --- /dev/null +++ b/scripts/check_pr.sh @@ -0,0 +1,125 @@ +#!/bin/bash +# Copyright (c) The Move Contributors +# SPDX-License-Identifier: Apache-2.0 +# +# A script to check whether a local commit is ready for a PR. +# This simulates CI checks locally + +set -e + +BUILD_FLAGS= + +BASE=$(git rev-parse --show-toplevel) +echo "*************** [check-pr] Assuming move root at $BASE" + +# Run only tests which would also be run on CI +export ENV_TEST_ON_CI=1 + +while getopts "htcgdea" opt; do + case $opt in + h) + cat < +Flags: + -h Print this help + -t Run tests + -c Run xclippy, xlint, and xfmt + -g Run the Move git checks script (whitespace check). This works + only for committed clients. + -d Run documentation generation, abi generation, etc. for move-stdlib + and other Move libraries. + -e Run hardhat EVM tests + -a All of the above + With no options script behaves like -tcg is given. + If you want to run tests in release mode, call this script as 'BUILD_FLAGS=-release