From 0f2ed1e291cf6f82446c349c6435645b173bb1d2 Mon Sep 17 00:00:00 2001 From: Jimmy Yuen Ho Wong Date: Tue, 5 Sep 2023 16:35:53 +0100 Subject: [PATCH] try passing input from one job to another --- .github/workflows/compile.yml | 17 +++++++++++------ .github/workflows/setup.yml | 10 ++++++++++ .github/workflows/test.yml | 24 ++++++++++++++---------- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 04e79d3..9eadea4 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -4,7 +4,13 @@ on: inputs: emacs-version: required: true - type: string + type: "string" + cache-key: + required: true + type: "string" + cache-path: + required: true + type: "string" jobs: compile: @@ -13,12 +19,11 @@ jobs: - uses: "actions/checkout@v3" - uses: "actions/cache/restore@v3" - id: emacs-cask-cache + id: "emacs-cask-cache" with: - path: | - /nix - ~/.emacs.d - key: "emacs-${{ inputs.emacs-version }}-cask-${{ hashFiles('Cask') }}" + path: "${{ inputs.cache-path }}" + key: "${{ inputs.cache-key }}" + fail-on-cache-miss: true - run: | make compile diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index 3b86000..d5cc20d 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -11,6 +11,9 @@ on: jobs: set_up: + outputs: + cache-path: "${{ steps.emacs-cask-cache.outputs.cache-path }}" + cache-key: "${{ steps.emacs-cask-cache.outputs.cache-key }}" runs-on: "ubuntu-latest" continue-on-error: "${{ matrix.experimental }}" strategy: @@ -42,6 +45,9 @@ jobs: ~/.cask ~/.emacs.d key: "emacs-${{ matrix.emacs-version }}-cask-${{ hashFiles('Cask') }}" + run: | + echo "cache-path=$INPUT_PATH" >> "$GITHUB_OUTPUT" + echo "cache-key=$INPUT_KEY" >> "$GITHUB_OUTPUT" - if: ${{ steps.emacs-cask-cache.outputs.cache-hit != 'true' }} uses: "purcell/setup-emacs@master" @@ -58,9 +64,13 @@ jobs: uses: "./.github/workflows/compile.yml" with: emacs-version: "${{ matrix.emacs-version }}" + cache-key: "${{ jobs.set_up.outputs.cache.key }}" + cache-path: "${{ jobs.set_up.outputs.cache.path }}" test: needs: "set_up" uses: "./.github/workflows/test.yml" with: emacs-version: "${{ matrix.emacs-version }}" + cache-key: "${{ jobs.set_up.outputs.cache.key }}" + cache-path: "${{ jobs.set_up.outputs.cache.path }}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ca3f8aa..547c745 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,21 +4,26 @@ on: inputs: emacs-version: required: true - type: string + type: "string" + cache-key: + required: true + type: "string" + cache-path: + required: true + type: "string" jobs: test: - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" steps: - uses: "actions/checkout@v3" - uses: "actions/cache/restore@v3" - id: emacs-cask-cache + id: "emacs-cask-cache" with: - path: | - /nix - ~/.emacs.d - key: "emacs-${{ inputs.emacs-version }}-cask-${{ hashFiles('Cask') }}" + path: "${{ inputs.cache-path }}" + key: "${{ inputs.cache-key }}" + fail-on-cache-miss: true - uses: "actions/setup-go@v4" with: @@ -26,9 +31,8 @@ jobs: check-latest: true cache: false - - name: "Install packages" + - id: "install-tomljson" run: | go install github.com/pelletier/go-toml/v2/cmd/tomljson@latest - - name: "Run tests" - run: | + - run: | make test