Skip to content

Commit

Permalink
[ci] Run CI on merge commit instead of head commit (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
sahithiacn committed Dec 29, 2022
1 parent a164e5c commit 9f4a169
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 88 deletions.
153 changes: 70 additions & 83 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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' }}
Expand All @@ -77,7 +77,7 @@ jobs:
target_os: [github]
steps:
- uses: actions/[email protected]
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 .
Expand All @@ -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' }}
Expand All @@ -98,8 +98,6 @@ jobs:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
with:
Expand All @@ -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' }}
Expand All @@ -128,9 +126,6 @@ jobs:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/[email protected]
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:
Expand Down Expand Up @@ -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' }}
Expand All @@ -173,8 +168,6 @@ jobs:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
- name: compile and install move-cli
Expand All @@ -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/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
- uses: actions/[email protected]
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/[email protected]
# - uses: ./.github/actions/build-setup
# - uses: actions/[email protected]
# 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/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/[email protected]
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/[email protected]
# - uses: actions/[email protected]
# 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/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Use Node.js 14
uses: actions/[email protected]
with:
Expand Down
29 changes: 24 additions & 5 deletions devtools/x/src/lint/license.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item = &'a str>) -> bool {
let maybe = maybe_license.collect::<Vec<_>>();
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;
Expand Down Expand Up @@ -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
Expand All @@ -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)
}
};

Expand Down
Loading

0 comments on commit 9f4a169

Please sign in to comment.