Skip to content

Commit b5ef4de

Browse files
dgunaySaschaManncoriolinus
authored
Replace Travis CI with GitHub Actions (#975)
* First attempt at breaking out Travis CI into GitHub Actions * Rename actions to run all tests * Rename missed name from GH actions template * delete travis.yml * delete leftover commented out code from template * Run tests on pushes to master and pull requests Co-authored-by: Sascha Mann <[email protected]> * first attempt at recreating build matrix * fix missing " in workflow * attempt to fix special-case nightly include * another attempt at making the file lint * Merge work to fix problems in GitHub Actions CI (#1) Various commits to a branch in the fork, squashed to avoid spamming the PR: * test1 * test2 * try putting entire expression in curly braces * big commit * delete comment * delete continue on error * delete not linting lines * Update tests.yml * comment out compilation job * add temp branch * uncomment compilation job * try using deny warnings * forgot what i did * fix nightly toolchain * try toolchain again * try toolchain again * try toolchain again * add travis env var * try changing master to origin/master to make actions not fail * add set -e -o pipefail to script * fail fast during CI for pull requests * add check PR files * look at git branch -a * try to check out master first * see if remotes origin master works * fix master branch path * checkout master for configlet job * fix master ref in ensure readmes updated * check out master for nightly * Squashed commit - should be pretty close to working as intended: commit 5790f28ef86d72c9bcc57344d6f5064d101c45f0 Author: Devin gunay <[email protected]> Date: Thu Oct 8 21:45:55 2020 -0700 probably working gh actions configuration commit 4c07754 Author: Devin gunay <[email protected]> Date: Thu Oct 8 21:43:21 2020 -0700 test if whole job fails commit 666653b Author: Devin gunay <[email protected]> Date: Thu Oct 8 21:38:50 2020 -0700 test failure on CI w denywarnings commit 641db7e Author: Devin gunay <[email protected]> Date: Thu Oct 8 21:25:41 2020 -0700 edit script to check cont on error commit 85801de Author: Devin gunay <[email protected]> Date: Thu Oct 8 21:18:18 2020 -0700 fix toolchain and try continue on error commit 1c2e590 Author: Devin gunay <[email protected]> Date: Thu Oct 8 21:08:11 2020 -0700 remove travis pr echo commit 4a623fc Author: Devin gunay <[email protected]> Date: Thu Oct 8 21:03:11 2020 -0700 print pr var commit c79f0c1 Author: Devin gunay <[email protected]> Date: Thu Oct 8 21:01:06 2020 -0700 try travis pr again commit 21ddc40 Author: Devin gunay <[email protected]> Date: Thu Oct 8 20:55:52 2020 -0700 set travis pr var conditionally commit 3a580b6 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 17:05:25 2020 -0700 check out master for nightly commit 67bb71d Author: Devin Gunay <[email protected]> Date: Wed Oct 7 17:02:51 2020 -0700 fix master ref in ensure readmes updated commit 05c6951 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 17:00:44 2020 -0700 checkout master for configlet job commit 9e31662 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 16:58:55 2020 -0700 fix master branch path commit 749a92c Author: Devin Gunay <[email protected]> Date: Wed Oct 7 16:55:21 2020 -0700 see if remotes origin master works commit 33a0704 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 16:54:21 2020 -0700 try to check out master first commit 8739869 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 16:51:03 2020 -0700 look at git branch -a commit 96001e2 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 16:46:16 2020 -0700 add check PR files commit 2be04c5 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 16:38:02 2020 -0700 fail fast during CI for pull requests commit 02101b2 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 16:36:08 2020 -0700 add set -e -o pipefail to script commit c5e255a Author: Devin Gunay <[email protected]> Date: Wed Oct 7 16:27:02 2020 -0700 try changing master to origin/master to make actions not fail commit 3b4395a Author: Devin Gunay <[email protected]> Date: Wed Oct 7 00:47:17 2020 -0700 add travis env var commit 497d3a3 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 00:26:24 2020 -0700 try toolchain again commit 359269f Author: Devin Gunay <[email protected]> Date: Wed Oct 7 00:25:37 2020 -0700 try toolchain again commit 04df9cb Author: Devin Gunay <[email protected]> Date: Wed Oct 7 00:24:41 2020 -0700 try toolchain again commit 42b6e16 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 00:18:00 2020 -0700 fix nightly toolchain commit 2c7354d Author: Devin Gunay <[email protected]> Date: Wed Oct 7 00:17:18 2020 -0700 forgot what i did commit 7560f0b Author: Devin Gunay <[email protected]> Date: Wed Oct 7 00:09:38 2020 -0700 try using deny warnings commit 80b6d76 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 00:07:15 2020 -0700 uncomment compilation job commit 5badd46 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 00:06:24 2020 -0700 add temp branch commit ef58cdb Author: Devin Gunay <[email protected]> Date: Wed Oct 7 00:05:27 2020 -0700 comment out compilation job commit 0ef5ed2 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 00:04:30 2020 -0700 Update tests.yml commit 66db311 Author: Devin Gunay <[email protected]> Date: Wed Oct 7 00:00:40 2020 -0700 delete not linting lines commit 803a507 Author: Devin Gunay <[email protected]> Date: Tue Oct 6 23:59:38 2020 -0700 delete continue on error commit c34c8f6 Author: Devin Gunay <[email protected]> Date: Tue Oct 6 23:58:33 2020 -0700 delete comment commit dbd4e1c Author: Devin Gunay <[email protected]> Date: Tue Oct 6 23:57:11 2020 -0700 big commit commit ba883ef Author: Devin Gunay <[email protected]> Date: Tue Oct 6 23:41:41 2020 -0700 try putting entire expression in curly braces commit 524b3e7 Author: Devin Gunay <[email protected]> Date: Tue Oct 6 23:40:25 2020 -0700 test2 commit 96c5547 Author: Devin Gunay <[email protected]> Date: Tue Oct 6 23:39:37 2020 -0700 test1 * remove leftover always true TRAVIS_PULL_REQUEST * shorten overall CI name for brevity * remove new comments in scripts Changing the behavior of the scripts is out of scope of this PR. If we see erroneous CI in the future, we can fix things then. We therefore don't need new comment-only changes in the scripts. Co-authored-by: Sascha Mann <[email protected]> Co-authored-by: Peter Goodspeed-Niklaus <[email protected]>
1 parent 585977d commit b5ef4de

File tree

7 files changed

+155
-37
lines changed

7 files changed

+155
-37
lines changed

.github/workflows/tests.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: CI
2+
3+
# Run this workflow every time a new commit is pushed to the repository
4+
on:
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
10+
jobs:
11+
ensure-conventions:
12+
name: Ensure conventions are followed
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
# Checks out a copy of your repository on the ubuntu-latest machine
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
20+
- name: Ensure src/lib.rs files exist
21+
run: bash ./_test/ensure-lib-src-rs-exist.sh
22+
23+
- name: Count ignores
24+
run: sh ./_test/count-ignores.sh
25+
26+
- name: Check UUIDs
27+
run: sh ./_test/check-uuids.sh
28+
29+
- name: Verify exercise difficulties
30+
run: ./_test/verify-exercise-difficulties.sh
31+
32+
- name: Check exercises for authors
33+
run: ./_test/check-exercises-for-authors.sh
34+
35+
configlet:
36+
name: Setup configlet
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
# Checks out master locally so that it is available to the scripts.
41+
- name: Checkout master
42+
uses: actions/checkout@v2
43+
with:
44+
ref: master
45+
46+
# Checks out a copy of your repository on the ubuntu-latest machine
47+
- name: Checkout code
48+
uses: actions/checkout@v2
49+
50+
# Sets TRAVIS_PULL_REQUEST to false if this is not a pull request.
51+
- name: set TRAVIS_PULL_REQUEST
52+
env:
53+
PR_NUMBER: ${{ github.event.pull_request.number }}
54+
run: echo "TRAVIS_PULL_REQUEST=${PR_NUMBER:-false}" >> $GITHUB_ENV
55+
56+
- name: Fetch configlet
57+
run: ./bin/fetch-configlet
58+
59+
- name: Check configlet format
60+
run: ./_test/check-configlet-fmt.sh
61+
62+
- name: Ensure readmes are updated
63+
run: sh ./_test/ensure-readmes-are-updated.sh
64+
65+
- name: Lint configlet
66+
run: ./bin/configlet lint .
67+
68+
69+
compilation:
70+
name: Check compilation
71+
runs-on: ubuntu-latest
72+
73+
strategy:
74+
# Allows running the job multiple times with different configurations
75+
matrix:
76+
rust: ["stable", "beta"]
77+
deny_warnings: ['', '1']
78+
79+
steps:
80+
# Checks out master locally so that it is available to the scripts.
81+
- name: Checkout master
82+
uses: actions/checkout@v2
83+
with:
84+
ref: master
85+
86+
# Checks out a copy of your repository on the ubuntu-latest machine
87+
- name: Checkout code
88+
uses: actions/checkout@v2
89+
90+
- name: Setup toolchain
91+
uses: actions-rs/toolchain@v1
92+
with:
93+
toolchain: ${{ matrix.rust }}
94+
default: true
95+
96+
# Sets TRAVIS_PULL_REQUEST to false if this is not a pull request.
97+
- name: set TRAVIS_PULL_REQUEST
98+
env:
99+
PR_NUMBER: ${{ github.event.pull_request.number }}
100+
run: echo "TRAVIS_PULL_REQUEST=${PR_NUMBER:-false}" >> $GITHUB_ENV
101+
102+
# run scripts as steps
103+
# TODO: the TRAVIS_PULL_REQUEST variable is a holdover from before the
104+
# migration to GitHub Actions. The scripts that use it do so in order to
105+
# run only on changed files.
106+
- name: Check exercises
107+
env:
108+
DENYWARNINGS: ${{ matrix.deny_warnings }}
109+
run: ./_test/check-exercises.sh
110+
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}
111+
112+
- name: Ensure stubs compile
113+
env:
114+
DENYWARNINGS: ${{ matrix.deny_warnings }}
115+
run: sh ./_test/ensure-stubs-compile.sh
116+
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}
117+
118+
- name: Check exercise crate
119+
env:
120+
DENYWARNINGS: ${{ matrix.deny_warnings }}
121+
run: sh ./_test/check-exercise-crate.sh
122+
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}
123+
124+
nightly-compilation:
125+
name: Check exercises on nightly (benchmark enabled)
126+
runs-on: ubuntu-latest
127+
continue-on-error: true # It's okay if the nightly job fails
128+
129+
steps:
130+
# Checks out master locally so that it is available to the scripts.
131+
- name: Checkout master
132+
uses: actions/checkout@v2
133+
with:
134+
ref: master
135+
136+
# Checks out a copy of your repository on the ubuntu-latest machine
137+
- name: Checkout code
138+
uses: actions/checkout@v2
139+
140+
- name: Setup nightly toolchain
141+
uses: actions-rs/toolchain@v1
142+
with:
143+
toolchain: nightly
144+
default: true
145+
146+
- name: Check exercises
147+
env:
148+
BENCHMARK: '1'
149+
run: ./_test/check-exercises.sh

.travis.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

_test/check-configlet-fmt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ check_pattern="config.json\|config/maintainers.json"
88

99
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
1010
# Check the changes on the current branch against master branch
11-
git diff --name-only master | grep "$check_pattern"
11+
git diff --name-only remotes/origin/master | grep "$check_pattern"
1212
else
1313
# Check the commits on the master branch made during the week
1414
# This is because Travis cron is set to test the master branch weekly.

_test/check-exercise-crate.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ EXERCISE_CRATE_PATH="util/exercise"
66

77
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
88
# Check the changes on the current branch against master branch
9-
git diff --name-only master | grep "$EXERCISE_CRATE_PATH"
9+
git diff --name-only remotes/origin/master | grep "$EXERCISE_CRATE_PATH"
1010
else
1111
# Check the commits on the master branch made during the week
1212
# This is because Travis cron is set to test the master branch weekly.
@@ -23,7 +23,7 @@ TRACK_ROOT="$(git rev-parse --show-toplevel)"
2323

2424
if !(cd "$TRACK_ROOT/$EXERCISE_CRATE_PATH" && cargo check); then
2525
echo "\nAn error has occurred while building the exercise crate.\nPlease make it compile."
26-
26+
2727
exit 1
2828
else
2929
echo "\nexercise crate has been successfully built."

_test/check-exercises.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fi
2828
repo=$(cd "$(dirname "$0")/.." && pwd)
2929

3030
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
31-
files="$(git diff --diff-filter=d --name-only master | grep "exercises/" | cut -d '/' -f -2 | sort -u | awk -v repo=$repo '{print repo"/"$1}')"
31+
files="$(git diff --diff-filter=d --name-only remotes/origin/master | grep "exercises/" | cut -d '/' -f -2 | sort -u | awk -v repo=$repo '{print repo"/"$1}')"
3232
else
3333
files=$repo/exercises/*
3434
fi

_test/ensure-readmes-are-updated.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ newline=$'\n '
1212

1313
missing_readmes=""
1414
wrong_readmes=""
15-
for exercise in $(git diff --diff-filter=d --name-only master..$(git rev-parse --abbrev-ref HEAD) | grep exercises/ | cut -d'/' -f2 -s | sort -fu); do
15+
for exercise in $(git diff --diff-filter=d --name-only remotes/origin/master..$(git rev-parse --abbrev-ref HEAD) | grep exercises/ | cut -d'/' -f2 -s | sort -fu); do
1616
echo "Checking readme for $exercise"
1717
readme_path="exercises/${exercise}/README.md"
1818
if [ ! -f $readme_path ]; then

_test/ensure-stubs-compile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
repo=$(cd "$(dirname "$0")/.." && pwd)
44

55
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
6-
changed_exercises="$(git diff --diff-filter=d --name-only master | grep "exercises/" | cut -d '/' -f -2 | sort -u | awk -v repo=$repo '{print repo"/"$1}')"
6+
changed_exercises="$(git diff --diff-filter=d --name-only remotes/origin/master | grep "exercises/" | cut -d '/' -f -2 | sort -u | awk -v repo=$repo '{print repo"/"$1}')"
77
else
88
changed_exercises=$repo/exercises/*
99
fi

0 commit comments

Comments
 (0)