From 39480908e9efda0a87fcb2c38c467bed18e37d98 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Mon, 15 Aug 2022 14:59:59 -0400 Subject: [PATCH] ci: split scripts and refine triggers (#8356) * ci: split scripts and refine triggers * ci: run on pr * Use original branch for check jobs * Manually trigger merge * use default refs * Add back branch --- .github/workflows/check-toc.yml | 53 ++++++++++++++++++ .github/workflows/check.yml | 56 ++----------------- .github/workflows/merge-dependabot.yml | 3 + .github/workflows/publish-to-npm.yml | 2 + .github/workflows/release-docs-and-schema.yml | 4 +- .github/workflows/test-docs.yml | 31 ++++++++++ .github/workflows/test.yml | 24 +------- scripts/check-and-commit-toc.sh | 3 - scripts/check-and-commit.sh | 3 - 9 files changed, 100 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/check-toc.yml create mode 100644 .github/workflows/test-docs.yml diff --git a/.github/workflows/check-toc.yml b/.github/workflows/check-toc.yml new file mode 100644 index 00000000000..21d4cb26304 --- /dev/null +++ b/.github/workflows/check-toc.yml @@ -0,0 +1,53 @@ +name: Check + +on: + workflow_dispatch: + pull_request: + paths: + - 'site/**' + - 'scripts/**' + +jobs: + toc: + name: TOC + if: "!contains(github.event.head_commit.message, '[ci skip]')" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.GH_PAT || github.token }} + ref: ${{ github.head_ref }} + + - name: Setup Node + uses: actions/setup-node@v3 + with: + cache: 'yarn' + + - name: Install Node dependencies + run: yarn --frozen-lockfile + + - name: Setup Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: '2.x' + + - name: Setup data + run: yarn data + + - name: Build Jekyll + run: | + gem install bundler + pushd site + bundle install + bundle exec jekyll build -q + popd + + - name: Build TOC + run: scripts/generate-toc + + - name: Setup Git remote + run: scripts/setup-git-ci.sh + + - name: Check and Commit + run: scripts/check-and-commit-toc.sh diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 90cee05c97e..93af350d601 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,9 +1,8 @@ name: Check on: - push: - branches: - - '**' + workflow_dispatch: + pull_request: jobs: check: @@ -14,6 +13,7 @@ jobs: - uses: actions/checkout@v3 with: token: ${{ secrets.GH_PAT || github.token }} + ref: ${{ github.head_ref }} - name: Setup Node uses: actions/setup-node@v3 @@ -35,60 +35,16 @@ jobs: sudo mv parallel sem /usr/local/bin - name: Format - if: github.ref != 'refs/heads/next' run: yarn format - name: Build Schema run: yarn schema - name: Check Schema - run: ./scripts/check-schema.sh + run: scripts/check-schema.sh - name: Setup Git remote - run: ./scripts/setup-git-ci.sh + run: scripts/setup-git-ci.sh - name: Check and Commit - run: ./scripts/check-and-commit.sh - - toc: - name: TOC - if: "!contains(github.event.head_commit.message, '[ci skip]')" - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - with: - token: ${{ secrets.GH_PAT || github.token }} - - - name: Setup Node - uses: actions/setup-node@v3 - with: - cache: 'yarn' - - - name: Install Node dependencies - run: yarn --frozen-lockfile - - - name: Setup Ruby - uses: actions/setup-ruby@v1 - with: - ruby-version: '2.x' - - - name: Setup data - run: yarn data - - - name: Build Jekyll - run: | - gem install bundler - pushd site - bundle install - bundle exec jekyll build -q - popd - - - name: Build TOC - run: scripts/generate-toc - - - name: Setup Git remote - run: ./scripts/setup-git-ci.sh - - - name: Check and Commit - run: ./scripts/check-and-commit-toc.sh + run: scripts/check-and-commit.sh diff --git a/.github/workflows/merge-dependabot.yml b/.github/workflows/merge-dependabot.yml index 4fb46f6c1c8..631b708ab43 100644 --- a/.github/workflows/merge-dependabot.yml +++ b/.github/workflows/merge-dependabot.yml @@ -1,7 +1,10 @@ name: Auto-merge Dependabot PRs + on: + workflow_dispatch: schedule: - cron: '0 * * * *' + jobs: auto_merge: name: Auto-merge Dependabot PRs diff --git a/.github/workflows/publish-to-npm.yml b/.github/workflows/publish-to-npm.yml index f93a134cf09..dad6b24aa65 100644 --- a/.github/workflows/publish-to-npm.yml +++ b/.github/workflows/publish-to-npm.yml @@ -7,6 +7,8 @@ on: - 'dependabot/**' # documentation site should not trigger releases - 'gh-pages' + paths-ignore: + - 'site/**' jobs: publish: diff --git a/.github/workflows/release-docs-and-schema.yml b/.github/workflows/release-docs-and-schema.yml index 6888cda26b5..8514797e4a8 100644 --- a/.github/workflows/release-docs-and-schema.yml +++ b/.github/workflows/release-docs-and-schema.yml @@ -27,7 +27,7 @@ jobs: run: yarn build - name: Setup Git remote - run: ./scripts/setup-git-ci.sh + run: scripts/setup-git-ci.sh env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -49,4 +49,4 @@ jobs: site-directory: 'site/' - name: Publish schema - run: ./scripts/deploy-schema.sh + run: scripts/deploy-schema.sh diff --git a/.github/workflows/test-docs.yml b/.github/workflows/test-docs.yml new file mode 100644 index 00000000000..a581ad046f6 --- /dev/null +++ b/.github/workflows/test-docs.yml @@ -0,0 +1,31 @@ +name: Test + +on: + workflow_dispatch: + pull_request: + paths: + - 'site/**' + - 'yarn.lock' + - '**prettier**' + +jobs: + build-site: + name: Build Site + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + cache: 'yarn' + + - name: Install Node dependencies + run: yarn --frozen-lockfile + + - name: Lint + run: yarn prettierbase --check + + - name: Build + run: yarn build:site diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0abc5d31672..bad02e35dd1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,10 @@ name: Test on: - push: - branches: - - next + workflow_dispatch: pull_request: + paths-ignore: + - 'site/**' jobs: test: @@ -31,24 +31,6 @@ jobs: - name: Build run: yarn build - build-site: - name: Build Site - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Setup Node - uses: actions/setup-node@v3 - with: - cache: 'yarn' - - - name: Install Node dependencies - run: yarn --frozen-lockfile - - - name: Build - run: yarn build:site - runtime-lint-coverage: name: Runtime, Linting, and Coverage runs-on: ubuntu-latest diff --git a/scripts/check-and-commit-toc.sh b/scripts/check-and-commit-toc.sh index 17a4fe988a6..f853cb8a69c 100755 --- a/scripts/check-and-commit-toc.sh +++ b/scripts/check-and-commit-toc.sh @@ -3,9 +3,6 @@ set -euo pipefail GIT_BRANCH="${GITHUB_REF/refs\/heads\//}" -git checkout $GIT_BRANCH - -echo "On branch $GIT_BRANCH." # Only push on human pull request branches. Exclude release, prerelease, and bot branches. if [ "$GIT_BRANCH" != "stable" ] && [ "$GIT_BRANCH" != "next" ] && [[ "$GIT_BRANCH" != dependabot/* ]]; then diff --git a/scripts/check-and-commit.sh b/scripts/check-and-commit.sh index 2212938cd4d..8f2e33b2131 100755 --- a/scripts/check-and-commit.sh +++ b/scripts/check-and-commit.sh @@ -3,9 +3,6 @@ set -euo pipefail GIT_BRANCH="${GITHUB_REF/refs\/heads\//}" -git checkout $GIT_BRANCH - -echo "On branch $GIT_BRANCH." # Only push on human pull request branches. Exclude release, prerelease, and bot branches. if [ "$GIT_BRANCH" != "stable" ] && [ "$GIT_BRANCH" != "next" ] && [[ "$GIT_BRANCH" != dependabot/* ]]; then