Skip to content

Commit 374c29b

Browse files
committed
Switch from Travis to GHA
1 parent c431f8c commit 374c29b

File tree

4 files changed

+94
-47
lines changed

4 files changed

+94
-47
lines changed

.env

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MDBOOK_VERSION=0.4.7
2+
MDBOOK_LINKCHECK_VERSION=0.7.2
3+
MDBOOK_TOC_VERSION=0.6.1
4+
DEPLOY_DIR=book/html

.github/workflows/ci.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
schedule:
9+
# Run at 18:00 UTC every day
10+
- cron: '0 18 * * *'
11+
12+
jobs:
13+
ci:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
# Set 0 to rebase later.
19+
fetch-depth: 0
20+
21+
- name: Read .env
22+
run: |
23+
. ./.env
24+
echo "MDBOOK_VERSION=${MDBOOK_VERSION}" >> $GITHUB_ENV
25+
echo "MDBOOK_LINKCHECK_VERSION=${MDBOOK_LINKCHECK_VERSION}" >> $GITHUB_ENV
26+
echo "MDBOOK_TOC_VERSION=${MDBOOK_TOC_VERSION}" >> $GITHUB_ENV
27+
echo "DEPLOY_DIR=${DEPLOY_DIR}" >> $GITHUB_ENV
28+
29+
- name: Cache binaries
30+
id: mdbook-cache
31+
uses: actions/cache@v2
32+
with:
33+
path: |
34+
~/.cargo/bin
35+
key: ${{ runner.os }}-${{ env.MDBOOK_VERSION }}--${{ env.MDBOOK_LINKCHECK_VERSION }}--${{ env.MDBOOK_TOC_VERSION }}
36+
37+
- name: Cache linkcheck
38+
uses: actions/cache@v2
39+
with:
40+
path: |
41+
~/book/linkcheck
42+
key: ${{ runner.os }}-${{ hashFiles('./book/linkcheck') }}
43+
44+
- name: Check line lengths
45+
if: github.event_name != 'schedule'
46+
run: |
47+
shopt -s globstar
48+
MAX_LINE_LENGTH=100 bash ci/check_line_lengths.sh src/**/*.md
49+
50+
- name: Install latest nightly Rust toolchain
51+
if: steps.mdbook-cache.outputs.cache-hit != 'true'
52+
uses: actions-rs/toolchain@v1
53+
with:
54+
toolchain: nightly
55+
override: true
56+
57+
- name: Install Dependencies
58+
if: steps.mdbook-cache.outputs.cache-hit != 'true'
59+
run: |
60+
cargo install mdbook --version ${{ env.MDBOOK_VERSION }}
61+
cargo install mdbook-linkcheck --version ${{ env.MDBOOK_LINKCHECK_VERSION }}
62+
cargo install mdbook-toc --version ${{ env.MDBOOK_TOC_VERSION }}
63+
64+
- name: Check build
65+
if: github.event_name != 'schedule'
66+
run: |
67+
git switch -c ci
68+
git fetch origin master
69+
git rebase origin/master
70+
git log --oneline | head -n 10
71+
mdbook build
72+
73+
- name: Deploy to gh-pages
74+
if: github.event_name == 'schedule' && github.repository == 'rust-lang/rustc-dev-guide'
75+
run: |
76+
mdbook build
77+
touch "${{ env.DEPLOY_DIR }}/.nojekyll"
78+
cp CNAME "${{ env.DEPLOY_DIR }}"
79+
cd "${{ env.DEPLOY_DIR }}"
80+
rm -rf .git
81+
git init
82+
git config user.name "Deploy from CI"
83+
git config user.email ""
84+
git add .
85+
git commit -m "Deploy ${GITHUB_SHA} to gh-pages"
86+
git push --quiet -f "https://x-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}" HEAD:gh-pages

.travis.yml

-39
This file was deleted.

ci/linkcheck.sh

+4-8
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,18 @@
33
set -e
44
set -o pipefail
55

6-
# https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
7-
if [ "$TRAVIS_EVENT_TYPE" = "cron" ] ; then # running in cron job
6+
# https://docs.github.com/en/actions/reference/environment-variables
7+
if [ "$GITHUB_EVENT_NAME" = "schedule" ] ; then # running in scheduled job
88
FLAGS=""
99

1010
echo "Doing full link check."
1111
set -x
1212
elif [ "$CI" = "true" ] ; then # running in PR CI build
13-
if [ -z "$TRAVIS_COMMIT_RANGE" ]; then
14-
echo "error: unexpected state: TRAVIS_COMMIT_RANGE must be non-empty in CI"
15-
exit 1
16-
fi
1713

18-
CHANGED_FILES=$(git diff --name-only $TRAVIS_COMMIT_RANGE | tr '\n' ' ')
14+
CHANGED_FILES=$(git diff --name-only origin/master... | tr '\n' ' ')
1915
FLAGS="--no-cache -f $CHANGED_FILES"
2016

21-
echo "Checking files changed in $TRAVIS_COMMIT_RANGE: $CHANGED_FILES"
17+
echo "Checking files changed in origin/master...: $CHANGED_FILES"
2218
set -x
2319
else # running locally
2420
COMMIT_RANGE=master...

0 commit comments

Comments
 (0)