Skip to content

Commit cb7465e

Browse files
committed
Auto merge of #5088 - rust-lang:gha, r=<try>
[WIP] Switch to GitHub Actions - Part 2 - From within This is a continuation of #5071. This time from a branch inside the rust-lang/rust-clippy repo, not from my fork, since secrets are not available in PRs from forks. Copying the description of #5071 to here: Closes #4577 ~~This is just an experiment. I don't think we have a consensus _if_ we should move away from travis/appveyor.~~ We have consensus: #5071 (comment) ~~GHA would let us run up to 20 concurrent jobs. Since we have 15 integration tests and 4 (linux, linux 32-bit, macos, windows) basic tests, we would be able to run everything concurrently.~~ The org has a limit of 60 jobs across the org, so we limit the matrix of the integration tests to 6 concurrent jobs. ~~Also IIUC we only have to build Clippy once for every initegration test and then only check the repos.~~ Nope, dependent jobs exist, but they won't keep the artifacts (not even the checkout). TODO before merge: - [x] Add `DEPLOY_KEY` secret to github repo - [x] test deployment on test branch `gh-test`# - [x] Test normal deployment - [x] Test deployment no changes - [x] Test deployment of tag - [x] talk with `@rust-lang/infra` for bors, `@rust-lang/infra` is good with the move (crater also uses GHA+bors) - [x] ~~Get remark + clippy_dev check to work on pushes (https://github.community/t5/GitHub-Actions/~Builds-are-not-triggered-with-on-paths/m-p/44075; I contacted GH support about this) ~~That seems to start working again yesterday 🤔 Let's hope it keeps working.~~ Or not: df9be48. Now it works again: 723786a. I think we should wait, until this is reliable. It appears, that it doesn't work on force pushes (sometimes?): 5814142~~ We need to run the bors tests unconditionally anyway (47138d1) so it doesn't really matter. - [ ] impl homu checks for GHA #5071 (comment) -- I prepared: flip1995/rust-central-station@f40230d. I'd suggest to first add GHA and keep the travis and appveyor checks for a few days and to remove them in a second pass. The bors dummy jobs are added in 1a83b7a and work as expected: #5088 (comment). I opened rust-lang/rust-central-station#578 - [x] ~Add GHA badge to Cargo.toml (blocked on rust-lang/crates.io # 1838)~ Added a FIXME in 2332b57 - [x] ~Maybe we should also wait until GHA supports yaml anchors. https://github.community/t5/GitHub-Actions/Support-for-YAML-anchors/td-p/30336/~ WIll probably not be implemented in the near future. - [x] Add back travis + appveyor files for transition period (!) changelog: none
2 parents 550affd + de2af6d commit cb7465e

24 files changed

+892
-213
lines changed

.github/deploy.sh

100755100644
+10-48
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
#!/bin/bash
22

3-
# Automatically deploy on gh-pages
4-
53
set -ex
64

7-
SOURCE_BRANCH="master"
8-
TARGET_BRANCH="gh-pages"
9-
10-
# Save some useful information
11-
REPO=$(git config remote.origin.url)
12-
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
13-
SHA=$(git rev-parse --verify HEAD)
14-
15-
# Clone the existing gh-pages for this repo into out/
16-
git clone --quiet --single-branch --branch "$TARGET_BRANCH" "$REPO" out
17-
185
echo "Removing the current docs for master"
196
rm -rf out/master/ || exit 0
207

@@ -23,59 +10,34 @@ mkdir out/master/
2310
cp util/gh-pages/index.html out/master
2411
python ./util/export.py out/master/lints.json
2512

26-
if [[ -n "$TRAVIS_TAG" ]]; then
27-
echo "Save the doc for the current tag ($TRAVIS_TAG) and point current/ to it"
28-
cp -r out/master "out/$TRAVIS_TAG"
29-
rm -f out/current
30-
ln -s "$TRAVIS_TAG" out/current
13+
if [[ -n $TAG_NAME ]]; then
14+
echo "Save the doc for the current tag ($TAG_NAME) and point current/ to it"
15+
cp -r out/master "out/$TAG_NAME"
16+
rm -f out/current
17+
ln -s "$TAG_NAME" out/current
3118
fi
3219

3320
# Generate version index that is shown as root index page
3421
cp util/gh-pages/versions.html out/index.html
35-
pushd out
3622

23+
cd out
3724
cat <<-EOF | python - > versions.json
3825
import os, json
3926
print json.dumps([
4027
dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
4128
])
4229
EOF
43-
popd
44-
45-
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
46-
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]] || [[ "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]]; then
47-
# Tags should deploy
48-
if [[ -z "$TRAVIS_TAG" ]]; then
49-
echo "Generated, won't push"
50-
exit 0
51-
fi
52-
fi
5330

5431
# Now let's go have some fun with the cloned repo
55-
cd out
56-
git config user.name "Travis CI"
57-
git config user.email "[email protected]"
32+
git config user.name "GHA CI"
33+
git config user.email "[email protected]"
5834

5935
if git diff --exit-code --quiet; then
60-
echo "No changes to the output on this push; exiting."
61-
exit 0
36+
echo "No changes to the output on this push; exiting."
37+
exit 0
6238
fi
63-
cd -
6439

65-
# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
66-
ENCRYPTION_LABEL=e3a2d77100be
67-
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
68-
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
69-
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
70-
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
71-
openssl aes-256-cbc -K "$ENCRYPTED_KEY" -iv "$ENCRYPTED_IV" -in .github/deploy_key.enc -out .github/deploy_key -d
72-
chmod 600 .github/deploy_key
73-
eval "$(ssh-agent -s)"
74-
ssh-add .github/deploy_key
75-
76-
cd out
7740
git add .
7841
git commit -m "Automatic deploy to GitHub Pages: ${SHA}"
7942

80-
# Now that we're all set up, we can push.
8143
git push "$SSH_REPO" "$TARGET_BRANCH"

.github/driver.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
# Check sysroot handling
6+
sysroot=$(./target/debug/clippy-driver --print sysroot)
7+
test "$sysroot" = "$(rustc --print sysroot)"
8+
9+
if [[ ${OS} == "Windows" ]]; then
10+
desired_sysroot=C:/tmp
11+
else
12+
desired_sysroot=/tmp
13+
fi
14+
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
15+
test "$sysroot" = $desired_sysroot
16+
17+
sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
18+
test "$sysroot" = $desired_sysroot
19+
20+
# Make sure this isn't set - clippy-driver should cope without it
21+
unset CARGO_MANIFEST_DIR
22+
23+
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
24+
# FIXME: How to match the clippy invocation in compile-test.rs?
25+
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
26+
sed -e "s,tests/ui,\$DIR," -e "/= help/d" cstring.stderr > normalized.stderr
27+
diff normalized.stderr tests/ui/cstring.stderr
28+
29+
# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR

.github/workflows/clippy.yml

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Clippy Test
2+
3+
on:
4+
push:
5+
# Ignore bors branches, since they are covered by `clippy_bors.yml`
6+
branches-ignore: [auto, try]
7+
# Don't run Clippy tests, when only textfiles were modified
8+
paths-ignore:
9+
- 'COPYRIGHT'
10+
- 'LICENSE-*'
11+
- '**.md'
12+
- '**.txt'
13+
pull_request:
14+
# Don't run Clippy tests, when only textfiles were modified
15+
paths-ignore:
16+
- 'COPYRIGHT'
17+
- 'LICENSE-*'
18+
- '**.md'
19+
- '**.txt'
20+
21+
env:
22+
RUST_BACKTRACE: 1
23+
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
24+
NO_FMT_TEST: 1
25+
26+
jobs:
27+
base:
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
# Setup
32+
- uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
33+
with:
34+
github_token: "${{ secrets.github_token }}"
35+
36+
- name: rust-toolchain
37+
uses: actions-rs/[email protected]
38+
with:
39+
toolchain: nightly
40+
target: x86_64-unknown-linux-gnu
41+
profile: minimal
42+
43+
- name: Checkout
44+
uses: actions/[email protected]
45+
46+
- name: Run cargo update
47+
run: cargo update
48+
49+
- name: Cache cargo dir
50+
uses: actions/cache@v1
51+
with:
52+
path: ~/.cargo
53+
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
54+
restore-keys: |
55+
${{ runner.os }}-x86_64-unknown-linux-gnu
56+
57+
- name: Master Toolchain Setup
58+
run: bash setup-toolchain.sh
59+
60+
# Run
61+
- name: Set LD_LIBRARY_PATH (Linux)
62+
run: |
63+
SYSROOT=$(rustc --print sysroot)
64+
echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}"
65+
66+
- name: Build
67+
run: cargo build --features deny-warnings
68+
69+
- name: Test
70+
run: cargo test --features deny-warnings
71+
72+
- name: Test clippy_lints
73+
run: cargo test --features deny-warnings
74+
working-directory: clippy_lints
75+
76+
- name: Test rustc_tools_util
77+
run: cargo test --features deny-warnings
78+
working-directory: rustc_tools_util
79+
80+
- name: Test clippy_dev
81+
run: cargo test --features deny-warnings
82+
working-directory: clippy_dev
83+
84+
- name: Test cargo-clippy
85+
run: ../target/debug/cargo-clippy
86+
working-directory: clippy_workspace_tests
87+
88+
- name: Test clippy-driver
89+
run: bash .github/driver.sh
90+
env:
91+
OS: ${{ runner.os }}
92+
93+
# Cleanup
94+
- name: Run cargo-cache --autoclean
95+
run: |
96+
cargo install cargo-cache --debug
97+
find ~/.cargo/bin ! -type d -exec strip {} \;
98+
cargo cache --autoclean

0 commit comments

Comments
 (0)