File tree Expand file tree Collapse file tree 5 files changed +21
-40
lines changed Expand file tree Collapse file tree 5 files changed +21
-40
lines changed Original file line number Diff line number Diff line change 47
47
- name : Checkout code
48
48
uses : actions/checkout@v2
49
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
50
- name : Fetch configlet
57
51
run : ./bin/fetch-configlet
58
52
93
87
toolchain : ${{ matrix.rust }}
94
88
default : true
95
89
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
90
# 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
91
- name : Check exercises
107
92
env :
108
93
DENYWARNINGS : ${{ matrix.deny_warnings }}
Original file line number Diff line number Diff line change 6
6
# Check if config.json or maintainers.json were modified
7
7
check_pattern=" config.json\|config/maintainers.json"
8
8
9
- if [ " $TRAVIS_PULL_REQUEST " ! = " false " ]; then
9
+ if [ " $GITHUB_EVENT_NAME " = " pull_request " ]; then
10
10
# Check the changes on the current branch against master branch
11
- git diff --name-only remotes/origin/master | grep " $check_pattern "
12
- else
13
- # Check the commits on the master branch made during the week
14
- # This is because Travis cron is set to test the master branch weekly.
15
- git diff --name-only " @{7 days ago}" | grep " $check_pattern "
16
- fi
17
-
18
- if [ $? != 0 ]; then
19
- echo " config.json or maintainers.json were not changed - configlet fmt is aborted."
20
-
21
- exit 0
11
+ if ! git diff --name-only remotes/origin/master | grep -q " $check_pattern " ; then
12
+ echo " config.json or maintainers.json were not changed - configlet fmt is aborted."
13
+ exit 0
14
+ fi
22
15
fi
16
+ # If it's not a pull request, just always run it.
17
+ # This script is cheap anyway.
23
18
24
19
repo=$( cd " $( dirname " $0 " ) /.." && pwd)
25
20
configlet=" ${repo} /bin/configlet"
Original file line number Diff line number Diff line change 4
4
5
5
EXERCISE_CRATE_PATH=" util/exercise"
6
6
7
- if [ " $TRAVIS_PULL_REQUEST " ! = " false " ]; then
7
+ if [ " $GITHUB_EVENT_NAME " = " pull_request " ]; then
8
8
# Check the changes on the current branch against master branch
9
- git diff --name-only remotes/origin/master | grep " $EXERCISE_CRATE_PATH "
10
- else
11
- # Check the commits on the master branch made during the week
12
- # This is because Travis cron is set to test the master branch weekly.
13
- git diff --name-only " @{7 days ago}" | grep " $EXERCISE_CRATE_PATH "
9
+ if ! git diff --name-only remotes/origin/master | grep -q " $EXERCISE_CRATE_PATH " ; then
10
+ echo " exercise crate was not modified. The script is aborted."
11
+ exit 0
12
+ fi
14
13
fi
14
+ # If it's not a pull request, just always run it.
15
+ # Two scenarios:
16
+ # 1. It's being run locally,
17
+ # in which case we assume the person running it really does want to run it.
18
+ # 2. It's being run on CI for master,
19
+ # in which case we should check regardless of changes to exercise crate,
20
+ # in case there's a new toolchain release, etc.
15
21
16
- if [ $? != 0 ]; then
17
- echo " exercise crate was not modified. The script is aborted."
18
-
19
- exit 0
20
- fi
21
22
22
23
TRACK_ROOT=" $( git rev-parse --show-toplevel) "
23
24
Original file line number Diff line number Diff line change 28
28
29
29
repo=$( cd " $( dirname " $0 " ) /.." && pwd)
30
30
31
- if [ " $TRAVIS_PULL_REQUEST " ! = " false " ]; then
31
+ if [ " $GITHUB_EVENT_NAME " = " pull_request " ]; then
32
32
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}' ) "
33
33
else
34
34
files=$repo /exercises/*
Original file line number Diff line number Diff line change 2
2
3
3
repo=$( cd " $( dirname " $0 " ) /.." && pwd)
4
4
5
- if [ " $TRAVIS_PULL_REQUEST " ! = " false " ]; then
5
+ if [ " $GITHUB_EVENT_NAME " = " pull_request " ]; then
6
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}' ) "
7
7
else
8
8
changed_exercises=$repo /exercises/*
You can’t perform that action at this time.
0 commit comments