Skip to content

Commit 9f4a169

Browse files
committed
[ci] Run CI on merge commit instead of head commit (#22)
1 parent a164e5c commit 9f4a169

File tree

3 files changed

+219
-88
lines changed

3 files changed

+219
-88
lines changed

.github/workflows/ci-test.yml

Lines changed: 70 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616

1717
jobs:
1818
prepare:
19-
runs-on: ubuntu-20.04
19+
runs-on: ubuntu-latest
2020
outputs:
2121
changes-target-branch: ${{ steps.changes.outputs.changes-target-branch }}
2222
changes-base-git-rev: ${{ steps.changes.outputs.changes-base-git-rev }}
@@ -67,7 +67,7 @@ jobs:
6767
pattern: 'docker/ci\|scripts/dev_setup.sh'
6868

6969
dev-setup-sh-test:
70-
runs-on: ubuntu-20.04-xl
70+
runs-on: ubuntu-latest
7171
timeout-minutes: 30
7272
needs: prepare
7373
if: ${{ needs.prepare.outputs.test-dev-setup == 'true' }}
@@ -77,7 +77,7 @@ jobs:
7777
target_os: [github]
7878
steps:
7979
- uses: actions/checkout@v2.4.0
80-
with:
80+
with:
8181
ref: ${{ github.event.pull_request.head.sha }}
8282
- name: build image with dev-setup.sh
8383
run: docker build -f docker/ci/${{ matrix.target_os }}/Dockerfile -t diem/build_environment:test .
@@ -88,7 +88,7 @@ jobs:
8888
github-token: ${{secrets.GITHUB_TOKEN}}
8989

9090
lint:
91-
runs-on: ubuntu-20.04-xl
91+
runs-on: ubuntu-latest
9292
timeout-minutes: 30
9393
needs: prepare
9494
if: ${{ needs.prepare.outputs.any-changes-founds == 'true' }}
@@ -98,8 +98,6 @@ jobs:
9898
- "${{github.workspace}}:/opt/git/diem"
9999
steps:
100100
- uses: actions/checkout@v2.4.0
101-
with:
102-
ref: ${{ github.event.pull_request.head.sha }}
103101
- uses: ./.github/actions/build-setup
104102
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
105103
with:
@@ -118,7 +116,7 @@ jobs:
118116
github-token: ${{secrets.GITHUB_TOKEN}}
119117

120118
unit-test:
121-
runs-on: ubuntu-20.04-xl
119+
runs-on: ubuntu-latest
122120
timeout-minutes: 60
123121
needs: prepare
124122
if: ${{ needs.prepare.outputs.test-rust == 'true' }}
@@ -128,9 +126,6 @@ jobs:
128126
- "${{github.workspace}}:/opt/git/diem"
129127
steps:
130128
- uses: actions/checkout@v2.4.0
131-
with:
132-
ref: ${{ github.event.pull_request.head.sha }}
133-
fetch-depth: 0 #get all the history!!!
134129
- uses: ./.github/actions/build-setup
135130
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
136131
with:
@@ -163,7 +158,7 @@ jobs:
163158
github-token: ${{secrets.GITHUB_TOKEN}}
164159

165160
hardhat-tests:
166-
runs-on: ubuntu-20.04-xl
161+
runs-on: ubuntu-latest
167162
timeout-minutes: 20
168163
needs: prepare
169164
if: ${{ needs.prepare.outputs.test-rust == 'true' }}
@@ -173,8 +168,6 @@ jobs:
173168
- "${{github.workspace}}:/opt/git/diem"
174169
steps:
175170
- uses: actions/checkout@v2.4.0
176-
with:
177-
ref: ${{ github.event.pull_request.head.sha }}
178171
- uses: ./.github/actions/build-setup
179172
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
180173
- name: compile and install move-cli
@@ -200,84 +193,78 @@ jobs:
200193
with:
201194
github-token: ${{secrets.GITHUB_TOKEN}}
202195

203-
# Compile (but don't run) the benchmarks, to insulate against bit rot
204-
build-benchmarks:
205-
runs-on: ubuntu-20.04-xl
206-
timeout-minutes: 30
207-
needs: prepare
208-
if: ${{ needs.prepare.outputs.test-rust == 'true' }}
209-
container:
210-
image: ghcr.io/diem/diem_build_environment:${{ needs.prepare.outputs.changes-target-branch }}
211-
volumes:
212-
- "${{github.workspace}}:/opt/git/diem"
213-
steps:
214-
- uses: actions/checkout@v2.4.0
215-
with:
216-
ref: ${{ github.event.pull_request.head.sha }}
217-
- uses: ./.github/actions/build-setup
218-
- uses: actions/cache@v2.1.6
219-
with:
220-
path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache"
221-
key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
222-
restore-keys: "crates-${{ runner.os }}"
223-
- name: build benchmarks
224-
run: cargo x bench --no-run
225-
- uses: ./.github/actions/build-teardown
226-
- name: Early terminate workflow
227-
if: ${{ failure() }}
228-
uses: ./.github/actions/early-terminator
229-
with:
230-
github-token: ${{secrets.GITHUB_TOKEN}}
196+
# # Compile (but don't run) the benchmarks, to insulate against bit rot
197+
# build-benchmarks:
198+
# runs-on: ubuntu-latest
199+
# timeout-minutes: 30
200+
# needs: prepare
201+
# if: ${{ needs.prepare.outputs.test-rust == 'true' }}
202+
# container:
203+
# image: ghcr.io/diem/diem_build_environment:${{ needs.prepare.outputs.changes-target-branch }}
204+
# volumes:
205+
# - "${{github.workspace}}:/opt/git/diem"
206+
# steps:
207+
# - uses: actions/checkout@v2.4.0
208+
# - uses: ./.github/actions/build-setup
209+
# - uses: actions/cache@v2.1.6
210+
# with:
211+
# path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache"
212+
# key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
213+
# restore-keys: "crates-${{ runner.os }}"
214+
# - name: build benchmarks
215+
# run: cargo x bench --no-run
216+
# - uses: ./.github/actions/build-teardown
217+
# - name: Early terminate workflow
218+
# if: ${{ failure() }}
219+
# uses: ./.github/actions/early-terminator
220+
# with:
221+
# github-token: ${{secrets.GITHUB_TOKEN}}
231222

232-
perf-benchmarks:
233-
name: run-perf-benchmarks
234-
runs-on: ubuntu-20.04-xl
235-
timeout-minutes: 30
236-
needs:
237-
- prepare
238-
- build-benchmarks
239-
env:
240-
CRITERION_HOME: /tmp/benches
241-
steps:
242-
- uses: actions/checkout@v2.4.0
243-
with:
244-
ref: ${{ github.event.pull_request.head.sha }}
245-
- uses: actions/cache@v2.1.6
246-
with:
247-
path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache"
248-
key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
249-
restore-keys: "crates-${{ runner.os }}"
250-
- name: Download the previous baseline
251-
continue-on-error: true
252-
uses: actions/download-artifact@v2
253-
with:
254-
name: bench-baseline
255-
- name: Run performance benchamrks
256-
run: |
257-
# Replace this with a cargo x bench
258-
cargo bench --package language-benchmarks
259-
- name: Archive criterion results
260-
uses: actions/upload-artifact@v2
261-
with:
262-
name: bench-baseline
263-
retention-days: 5
264-
path: |
265-
/tmp/benches
266-
- name: Early terminate workflow
267-
if: ${{ failure() }}
268-
uses: ./.github/actions/early-terminator
269-
with:
270-
github-token: ${{secrets.GITHUB_TOKEN}}
223+
# perf-benchmarks:
224+
# name: run-perf-benchmarks
225+
# runs-on: ubuntu-latest
226+
# timeout-minutes: 30
227+
# needs:
228+
# - prepare
229+
# - build-benchmarks
230+
# env:
231+
# CRITERION_HOME: /tmp/benches
232+
# steps:
233+
# - uses: actions/checkout@v2.4.0
234+
# - uses: actions/cache@v2.1.6
235+
# with:
236+
# path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache"
237+
# key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
238+
# restore-keys: "crates-${{ runner.os }}"
239+
# - name: Download the previous baseline
240+
# continue-on-error: true
241+
# uses: actions/download-artifact@v2
242+
# with:
243+
# name: bench-baseline
244+
# - name: Run performance benchamrks
245+
# run: |
246+
# # Replace this with a cargo x bench
247+
# cargo bench --package language-benchmarks
248+
# - name: Archive criterion results
249+
# uses: actions/upload-artifact@v2
250+
# with:
251+
# name: bench-baseline
252+
# retention-days: 5
253+
# path: |
254+
# /tmp/benches
255+
# - name: Early terminate workflow
256+
# if: ${{ failure() }}
257+
# uses: ./.github/actions/early-terminator
258+
# with:
259+
# github-token: ${{secrets.GITHUB_TOKEN}}
271260

272261
build-move-analyzer-vscode-extension:
273262
name: Build VS Code extension for move-analyzer
274-
runs-on: ubuntu-20.04
263+
runs-on: ubuntu-latest
275264
needs:
276265
- prepare
277266
steps:
278267
- uses: actions/checkout@v2.4.0
279-
with:
280-
ref: ${{ github.event.pull_request.head.sha }}
281268
- name: Use Node.js 14
282269
uses: actions/setup-node@v2.4.0
283270
with:

devtools/x/src/lint/license.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,28 @@
33

44
use x_lint::prelude::*;
55

6-
static LICENSE_HEADER: &str = "Copyright (c) The Diem Core Contributors\n\
7-
SPDX-License-Identifier: Apache-2.0\n\
8-
";
6+
static ALLOWED_LICENSE_HEADERS: &[&str] = &[
7+
"Copyright (c) The Move Contributors\n\
8+
SPDX-License-Identifier: Apache-2.0\n\
9+
",
10+
"Copyright (c) The Diem Core Contributors\n\
11+
SPDX-License-Identifier: Apache-2.0\n\
12+
",
13+
"Copyright (c) The Move Contributors\n\
14+
Copyright (c) The Diem Core Contributors\n\
15+
SPDX-License-Identifier: Apache-2.0\n\
16+
",
17+
];
18+
19+
fn has_license<'a>(maybe_license: impl Iterator<Item = &'a str>) -> bool {
20+
let maybe = maybe_license.collect::<Vec<_>>();
21+
for allowed in ALLOWED_LICENSE_HEADERS {
22+
if allowed.lines().eq(maybe.clone().into_iter()) {
23+
return true;
24+
}
25+
}
26+
false
27+
}
928

1029
#[derive(Copy, Clone, Debug)]
1130
pub(super) struct LicenseHeader;
@@ -50,7 +69,7 @@ impl ContentLinter for LicenseHeader {
5069
.skip_while(|line| line.is_empty())
5170
.take(2)
5271
.map(|s| s.trim_start_matches("// "));
53-
!LICENSE_HEADER.lines().eq(maybe_license)
72+
!has_license(maybe_license)
5473
}
5574
FileType::Shell => {
5675
let maybe_license = content
@@ -59,7 +78,7 @@ impl ContentLinter for LicenseHeader {
5978
.skip_while(|line| line.is_empty())
6079
.take(2)
6180
.map(|s| s.trim_start_matches("# "));
62-
!LICENSE_HEADER.lines().eq(maybe_license)
81+
!has_license(maybe_license)
6382
}
6483
};
6584

0 commit comments

Comments
 (0)