diff --git a/.env b/.env deleted file mode 100644 index 6923d3796..000000000 --- a/.env +++ /dev/null @@ -1,4 +0,0 @@ -MDBOOK_VERSION=0.4.7 -MDBOOK_LINKCHECK_VERSION=0.7.2 -MDBOOK_TOC_VERSION=0.6.1 -DEPLOY_DIR=book/html diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2edc33e16..b7a33dd4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,20 +12,18 @@ on: jobs: ci: runs-on: ubuntu-latest + env: + MDBOOK_VERSION: 0.4.7 + MDBOOK_LINKCHECK_VERSION: 0.7.2 + MDBOOK_TOC_VERSION: 0.6.1 + DEPLOY_DIR: book/html + BASE_SHA: ${{ github.event.pull_request.base.sha }} steps: - uses: actions/checkout@v2 with: # Set 0 to rebase later. fetch-depth: 0 - - name: Read .env - run: | - . ./.env - echo "MDBOOK_VERSION=${MDBOOK_VERSION}" >> $GITHUB_ENV - echo "MDBOOK_LINKCHECK_VERSION=${MDBOOK_LINKCHECK_VERSION}" >> $GITHUB_ENV - echo "MDBOOK_TOC_VERSION=${MDBOOK_TOC_VERSION}" >> $GITHUB_ENV - echo "DEPLOY_DIR=${DEPLOY_DIR}" >> $GITHUB_ENV - - name: Cache binaries id: mdbook-cache uses: actions/cache@v2 @@ -42,7 +40,7 @@ jobs: key: ${{ runner.os }}-${{ hashFiles('./book/linkcheck') }} - name: Check line lengths - if: github.event_name != 'schedule' + if: github.event_name != 'push' run: | shopt -s globstar MAX_LINE_LENGTH=100 bash ci/check_line_lengths.sh src/**/*.md @@ -62,7 +60,7 @@ jobs: cargo install mdbook-toc --version ${{ env.MDBOOK_TOC_VERSION }} - name: Check build - if: github.event_name != 'schedule' + if: github.event_name != 'push' run: | git switch -c ci git fetch origin master @@ -71,7 +69,7 @@ jobs: mdbook build - name: Deploy to gh-pages - if: github.event_name == 'schedule' && github.repository == 'rust-lang/rustc-dev-guide' + if: github.event_name == 'push' && github.repository == 'rust-lang/rustc-dev-guide' run: | mdbook build touch "${{ env.DEPLOY_DIR }}/.nojekyll" diff --git a/ci/linkcheck.sh b/ci/linkcheck.sh index 86ee000cb..abf1feb51 100755 --- a/ci/linkcheck.sh +++ b/ci/linkcheck.sh @@ -10,11 +10,15 @@ if [ "$GITHUB_EVENT_NAME" = "schedule" ] ; then # running in scheduled job echo "Doing full link check." set -x elif [ "$CI" = "true" ] ; then # running in PR CI build + if [ -z "$BASE_SHA" ]; then + echo "error: unexpected state: BASE_SHA must be non-empty in CI" + exit 1 + fi - CHANGED_FILES=$(git diff --name-only origin/master... | tr '\n' ' ') + CHANGED_FILES=$(git diff --name-only $BASE_SHA...$GITHUB_SHA | tr '\n' ' ') FLAGS="--no-cache -f $CHANGED_FILES" - echo "Checking files changed in origin/master...: $CHANGED_FILES" + echo "Checking files changed in $BASE_SHA...$GITHUB_SHA: $CHANGED_FILES" set -x else # running locally COMMIT_RANGE=master...