Skip to content

Commit f107250

Browse files
committed
Auto merge of #5088 - rust-lang:gha, r=<try>
[WIP][DNM] 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) - [ ] 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 - [ ] impl homu checks for GHA #5071 (comment) - [ ] Add GHA badge to Cargo.toml (blocked on rust-lang/crates.io # 1838) - [ ] Maybe we should also wait until GHA supports yaml anchors. https://github.community/t5/GitHub-Actions/Support-for-YAML-anchors/td-p/30336/ - [ ] Add back travis + appveyor files for transition period (?) changelog: none
2 parents d33c603 + 6f68fd8 commit f107250

27 files changed

+842
-460
lines changed

.github/deploy.sh

100755100644
+11-49
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1-
#!/bin/bash
2-
3-
# Automatically deploy on gh-pages
1+
#! /bin/bash
42

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/deploy_key.enc

-1.64 KB
Binary file not shown.

.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

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
GHA_CI: 1
25+
26+
jobs:
27+
base:
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
32+
with:
33+
github_token: "${{ secrets.github_token }}"
34+
- name: rust-toolchain
35+
uses: actions-rs/[email protected]
36+
with:
37+
toolchain: nightly
38+
target: x86_64-unknown-linux-gnu
39+
profile: minimal
40+
- name: Checkout
41+
uses: actions/[email protected]
42+
- name: Run cargo update
43+
run: cargo update
44+
- name: Cache cargo dir
45+
uses: actions/cache@v1
46+
with:
47+
path: ~/.cargo
48+
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
49+
restore-keys: |
50+
${{ runner.os }}-x86_64-unknown-linux-gnu
51+
- name: Master Toolchain Setup
52+
run: bash setup-toolchain.sh
53+
54+
- name: Set LD_LIBRARY_PATH (Linux)
55+
run: |
56+
SYSROOT=$(rustc --print sysroot)
57+
echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}"
58+
- name: Build
59+
run: cargo build --features deny-warnings
60+
- name: Test
61+
run: cargo test --features deny-warnings
62+
- name: Test clippy_lints
63+
run: cargo test --features deny-warnings
64+
working-directory: clippy_lints
65+
- name: Test rustc_tools_util
66+
run: cargo test --features deny-warnings
67+
working-directory: rustc_tools_util
68+
- name: Test clippy_dev
69+
run: cargo test --features deny-warnings
70+
working-directory: clippy_dev
71+
- name: Test cargo-clippy
72+
run: ../target/debug/cargo-clippy
73+
working-directory: clippy_workspace_tests
74+
- name: Test clippy-driver
75+
run: bash .github/driver.sh
76+
env:
77+
OS: ${{ runner.os }}
78+
79+
- name: Run cargo-cache --autoclean
80+
run: |
81+
cargo install cargo-cache --debug
82+
find ~/.cargo/bin ! -type d -exec strip {} \;
83+
cargo cache --autoclean

0 commit comments

Comments
 (0)