From b6f9fbfee05fe035844e892e628a814a18a4d025 Mon Sep 17 00:00:00 2001 From: schillic Date: Sun, 4 Feb 2024 10:12:19 +0100 Subject: [PATCH] revise CI scripts --- .github/workflows/CompatHelper.yml | 25 ++++--- .github/workflows/SpellCheck.yml | 13 ---- .github/workflows/TagBot.yml | 6 +- ...n-gh-pages.yml => doc-preview-cleanup.yml} | 10 +-- .../workflows/{docs.yml => documentation.yml} | 20 ++++-- .github/workflows/format.yml | 20 +++--- .github/workflows/invalidations.yml | 68 ++++++++++--------- .github/workflows/spell-check.yml | 18 +++++ .github/workflows/{ci.yml => test-master.yml} | 12 ++-- .../{ci_PR.yml => test-pull-request.yml} | 12 ++-- 10 files changed, 119 insertions(+), 85 deletions(-) delete mode 100644 .github/workflows/SpellCheck.yml rename .github/workflows/{clean-gh-pages.yml => doc-preview-cleanup.yml} (78%) rename .github/workflows/{docs.yml => documentation.yml} (70%) create mode 100644 .github/workflows/spell-check.yml rename .github/workflows/{ci.yml => test-master.yml} (83%) rename .github/workflows/{ci_PR.yml => test-pull-request.yml} (85%) diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index 186d654..294df89 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -1,21 +1,30 @@ +# https://github.com/JuliaRegistries/CompatHelper.jl name: CompatHelper - on: schedule: - - cron: '00 00 * * *' + - cron: '0 0 * * *' # every day at midnight workflow_dispatch: - jobs: CompatHelper: runs-on: ubuntu-latest steps: - - uses: julia-actions/setup-julia@latest + - name: Check if Julia is already available + id: julia_in_path + run: which julia + continue-on-error: true + - name: Set up Julia if not already available + uses: julia-actions/setup-julia@v1 with: version: '1' - - name: Pkg.add("CompatHelper") - run: julia -e 'using Pkg; Pkg.add("CompatHelper")' - - name: CompatHelper.main() + arch: ${{ runner.arch }} + if: steps.julia_in_path.outcome != 'success' + - name: Install CompatHelper + run: julia -e 'import Pkg; Pkg.add("CompatHelper")' + - name: Run CompatHelper + run: | + julia -e 'import CompatHelper; + CompatHelper.main(; subdirs=["", "test", "docs"], + bump_compat_containing_equality_specifier=false)' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} - run: julia -e 'using CompatHelper; CompatHelper.main(; subdirs=["", "test", "docs"], bump_compat_containing_equality_specifier=false)' diff --git a/.github/workflows/SpellCheck.yml b/.github/workflows/SpellCheck.yml deleted file mode 100644 index fe7db59..0000000 --- a/.github/workflows/SpellCheck.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Spell Check - -on: [pull_request] - -jobs: - typos-check: - name: check spelling - runs-on: ubuntu-latest - steps: - - name: Checkout Actions Repository - uses: actions/checkout@v4 - - name: Check spelling - uses: crate-ci/typos@master diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml index 6887673..7cf69bb 100644 --- a/.github/workflows/TagBot.yml +++ b/.github/workflows/TagBot.yml @@ -1,16 +1,16 @@ +# https://github.com/JuliaRegistries/TagBot name: TagBot - on: issue_comment: types: - created workflow_dispatch: - jobs: TagBot: if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' runs-on: ubuntu-latest steps: - - uses: JuliaRegistries/TagBot@v1 + - name: Create new release tag + uses: JuliaRegistries/TagBot@v1 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/clean-gh-pages.yml b/.github/workflows/doc-preview-cleanup.yml similarity index 78% rename from .github/workflows/clean-gh-pages.yml rename to .github/workflows/doc-preview-cleanup.yml index 94b9f70..f420140 100644 --- a/.github/workflows/clean-gh-pages.yml +++ b/.github/workflows/doc-preview-cleanup.yml @@ -1,9 +1,9 @@ -name: Doc Preview Cleanup - +# https://documenter.juliadocs.org/stable/man/hosting/#Cleaning-up-gh-pages +name: Doc preview cleanup on: - pull_request: + pull_request_target: types: [closed] - + workflow_dispatch: jobs: doc-preview-cleanup: runs-on: ubuntu-latest @@ -12,7 +12,7 @@ jobs: uses: actions/checkout@v4 with: ref: gh-pages - - name: Delete preview and history + push changes + - name: Delete preview and history run: | if [ -d "previews/PR$PRNUM" ]; then git config user.name "Documenter.jl" diff --git a/.github/workflows/docs.yml b/.github/workflows/documentation.yml similarity index 70% rename from .github/workflows/docs.yml rename to .github/workflows/documentation.yml index a9f31cb..26a392d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/documentation.yml @@ -1,5 +1,5 @@ +# https://documenter.juliadocs.org/stable/man/hosting/#GitHub-Actions name: Documentation - on: push: paths-ignore: @@ -7,32 +7,38 @@ on: - 'README.md' branches: - master - tags: '*' pull_request: paths-ignore: - 'LICENSE' - 'README.md' - + workflow_dispatch: +concurrency: + # cancel intermediate builds + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: build: runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip ci')" env: JULIA_PKG_SERVER: '' steps: - - name: Check out repository - uses: actions/checkout@v4 - name: Set up Julia - uses: julia-actions/setup-julia@latest + uses: julia-actions/setup-julia@v1 with: version: '1' + - name: Check out repository + uses: actions/checkout@v4 + - name: Cache artifacts + uses: julia-actions/cache@v1 - name: Install dependencies run: | julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - name: Build and deploy + run: julia --project=docs/ docs/make.jl env: GKSwstype: nul # fix for Plots with GR backend GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # authentication with GitHub Actions token DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # authentication with SSH deploy key - run: julia --project=docs/ docs/make.jl diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 11bb716..b6b075e 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,20 +1,20 @@ -name: Format +# https://github.com/julia-actions/julia-format +name: Format code on: schedule: - cron: '0 0 * * 6' # every Saturday at 0:00 + workflow_dispatch: jobs: - build: + format: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Check out repository + uses: actions/checkout@v4 + - name: Cache artifacts + uses: julia-actions/cache@v1 - name: Install JuliaFormatter and format - run: | - julia -e 'import Pkg; Pkg.add("JuliaFormatter")' - julia -e 'using JuliaFormatter; format(".")' - - # https://github.com/marketplace/actions/create-pull-request - # https://github.com/peter-evans/create-pull-request#reference-example - - name: Create Pull Request + run: julia -e 'import Pkg; Pkg.add("JuliaFormatter"); using JuliaFormatter; format(".")' + - name: Create pull request id: cpr uses: peter-evans/create-pull-request@v5 with: diff --git a/.github/workflows/invalidations.yml b/.github/workflows/invalidations.yml index 96bd792..9fa9636 100644 --- a/.github/workflows/invalidations.yml +++ b/.github/workflows/invalidations.yml @@ -1,45 +1,51 @@ # https://github.com/julia-actions/julia-invalidations name: Invalidations - on: pull_request: paths-ignore: - 'LICENSE' - 'README.md' - + workflow_dispatch: concurrency: - # Skip intermediate builds: always. - # Cancel intermediate builds: always. + # cancel intermediate builds group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - jobs: evaluate: - # Only run on PRs to the default branch. - # In the PR trigger above branches can be specified only explicitly whereas this check should work for master, main, or any other default branch - if: github.base_ref == github.event.repository.default_branch runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip ci')" + env: + JULIA_PKG_SERVER: '' steps: - - uses: julia-actions/setup-julia@v1 - with: - version: '1' - - - uses: actions/checkout@v4 - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-invalidations@v1 - id: invs_pr - - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.repository.default_branch }} - - uses: julia-actions/julia-buildpkg@v1 - - uses: julia-actions/julia-invalidations@v1 - id: invs_default - - - name: Report invalidation counts - run: | - echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY - echo "This branch: ${{ steps.invs_pr.outputs.total }} (${{ steps.invs_pr.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY - - name: Check if the PR does increase number of invalidations - if: steps.invs_pr.outputs.total > steps.invs_default.outputs.total - run: exit 1 + - name: Set up Julia + uses: julia-actions/setup-julia@v1 + with: + version: '1' + # current branch + - name: Check out repository in current branch + uses: actions/checkout@v4 + - name: Cache artifacts + uses: julia-actions/cache@v1 + - name: Build package in current branch + uses: julia-actions/julia-buildpkg@v1 + - name: Count invalidations in current branch + uses: julia-actions/julia-invalidations@v1 + id: invs_branch + # default branch + - name: Check out repository in default branch + uses: actions/checkout@v4 + with: + ref: ${{ github.event.repository.default_branch }} + - name: Build package in default branch + uses: julia-actions/julia-buildpkg@v1 + - name: Count invalidations in default branch + uses: julia-actions/julia-invalidations@v1 + id: invs_default + # aggregate results + - name: Report invalidation counts + run: | + echo "Invalidations on default branch: ${{ steps.invs_default.outputs.total }} (${{ steps.invs_default.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY + echo "Invalidations on this branch: ${{ steps.invs_branch.outputs.total }} (${{ steps.invs_branch.outputs.deps }} via deps)" >> $GITHUB_STEP_SUMMARY + - name: Check whether branch increases invalidations + if: steps.invs_branch.outputs.total > steps.invs_default.outputs.total + run: exit 1 diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml new file mode 100644 index 0000000..76902d8 --- /dev/null +++ b/.github/workflows/spell-check.yml @@ -0,0 +1,18 @@ +# https://github.com/crate-ci/typos +name: Spell check +on: + pull_request: + workflow_dispatch: +concurrency: + # cancel intermediate builds + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + spell-check: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip ci')" + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Check spelling + uses: crate-ci/typos@master diff --git a/.github/workflows/ci.yml b/.github/workflows/test-master.yml similarity index 83% rename from .github/workflows/ci.yml rename to .github/workflows/test-master.yml index b6df2f6..95c80ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/test-master.yml @@ -1,5 +1,5 @@ -name: CI - +# https://github.com/julia-actions/julia-runtest +name: Test on: push: paths-ignore: @@ -7,10 +7,14 @@ on: - 'README.md' branches: - master - + workflow_dispatch: +concurrency: + # cancel intermediate builds + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: test: - name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} runs-on: ${{ matrix.os }} if: "!contains(github.event.head_commit.message, 'skip ci')" strategy: diff --git a/.github/workflows/ci_PR.yml b/.github/workflows/test-pull-request.yml similarity index 85% rename from .github/workflows/ci_PR.yml rename to .github/workflows/test-pull-request.yml index aa942ea..189011b 100644 --- a/.github/workflows/ci_PR.yml +++ b/.github/workflows/test-pull-request.yml @@ -1,14 +1,18 @@ -name: CI-PR - +# https://github.com/julia-actions/julia-runtest +name: Test on: pull_request: paths-ignore: - 'LICENSE' - 'README.md' - + workflow_dispatch: +concurrency: + # cancel intermediate builds + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: test: - name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} runs-on: ${{ matrix.os }} if: "!contains(github.event.head_commit.message, 'skip ci')" strategy: