From ea92cfd57a6ab80c38df8e122ef1f3888af2d283 Mon Sep 17 00:00:00 2001 From: Jimmy Yuen Ho Wong Date: Tue, 5 Sep 2023 15:17:25 +0100 Subject: [PATCH] give cache and reusable workflows a try --- .github/workflows/compile.yml | 24 +++++++++++ .github/workflows/setup.yml | 59 +++++++++++++++++++++++++++ .github/workflows/test.yml | 76 ++++++++--------------------------- 3 files changed, 99 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/compile.yml create mode 100644 .github/workflows/setup.yml diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml new file mode 100644 index 0000000..04e79d3 --- /dev/null +++ b/.github/workflows/compile.yml @@ -0,0 +1,24 @@ +name: "Compile" +on: + workflow_call: + inputs: + emacs-version: + required: true + type: string + +jobs: + compile: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v3" + + - uses: "actions/cache/restore@v3" + id: emacs-cask-cache + with: + path: | + /nix + ~/.emacs.d + key: "emacs-${{ inputs.emacs-version }}-cask-${{ hashFiles('Cask') }}" + + - run: | + make compile diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml new file mode 100644 index 0000000..eec6a65 --- /dev/null +++ b/.github/workflows/setup.yml @@ -0,0 +1,59 @@ +name: "Set up" +on: + push: + paths-ignore: + - "README.rst" + branches: + - "main" + pull_request: + branches: + - "*" + +jobs: + set_up: + runs-on: "ubuntu-latest" + continue-on-error: "${{ matrix.experimental }}" + strategy: + fail-fast: false + matrix: + emacs-version: + - "26.1" + - "26.2" + - "26.3" + - "27.1" + - "27.2" + - "28.1" + - "28.2" + - "29.1" + experimental: [false] + include: + - emacs-version: "snapshot" + experimental: true + + steps: + - uses: "actions/checkout@v4" + + - uses: "actions/cache@v3" + id: "emacs-cask-cache" + with: + path: | + /nix + ~/.emacs.d + key: "emacs-${{ matrix.emacs-version }}-cask-${{ hashFiles('Cask') }}" + + - if: ${{ steps.emacs-cask-cache.outputs.cache-hit != 'true' } + uses: "purcell/setup-emacs@master" + with: + version: "${{ matrix.emacs-version }}" + + - if: ${{ steps.emacs-cask-cache.outputs.cache-hit != 'true' } + uses: "cask/setup-cask@master" + with: + version: "0.9.0" + + - uses: "./compile.yml" + with: + emacs-version: "${{ matrix.emacs-version }}" + - uses: "./test.yml" + with: + emacs-version: "${{ matrix.emacs-version }}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82d7db9..ca3f8aa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,75 +1,31 @@ +name: "Test" on: - push: - paths-ignore: - - "README.rst" - branches: - - "main" - pull_request: - branches: - - "*" -jobs: - compile: - runs-on: "ubuntu-latest" - continue-on-error: ${{ matrix.experimental }} - strategy: - fail-fast: false - matrix: - emacs-version: - - "26.1" - - "26.2" - - "26.3" - - "27.1" - - "27.2" - - "28.1" - - "28.2" - - "29.1" - experimental: [false] - include: - - emacs-version: snapshot - experimental: true - steps: - - uses: "actions/checkout@v3" - - uses: "purcell/setup-emacs@master" - with: - version: ${{ matrix.emacs-version }} - - uses: "cask/setup-cask@master" - with: - version: "0.9.0" - - run: | - make compile + workflow_call: + inputs: + emacs-version: + required: true + type: string +jobs: test: runs-on: ubuntu-latest - continue-on-error: ${{ matrix.experimental }} - strategy: - fail-fast: false - matrix: - emacs-version: - - "26.1" - - "26.2" - - "26.3" - - "27.1" - - "27.2" - - "28.1" - - "28.2" - - "29.1" - experimental: [false] - include: - - emacs-version: snapshot - experimental: true steps: - uses: "actions/checkout@v3" - - uses: "purcell/setup-emacs@master" - with: - version: ${{ matrix.emacs-version }} - - uses: "cask/setup-cask@master" + + - uses: "actions/cache/restore@v3" + id: emacs-cask-cache with: - version: "0.9.0" + path: | + /nix + ~/.emacs.d + key: "emacs-${{ inputs.emacs-version }}-cask-${{ hashFiles('Cask') }}" + - uses: "actions/setup-go@v4" with: go-version: "stable" check-latest: true cache: false + - name: "Install packages" run: | go install github.com/pelletier/go-toml/v2/cmd/tomljson@latest