Skip to content

Commit

Permalink
* fix not saving action/cache after failed jobs @ actions/{be,fe,c#…
Browse files Browse the repository at this point in the history
…}/action.yml

@ .github
  • Loading branch information
n0099 committed Feb 12, 2024
1 parent 33424ba commit 96955ac
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 15 deletions.
22 changes: 16 additions & 6 deletions .github/actions/be/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,29 @@ runs:
ini-values: opcache.enable_cli=1
env: # https://github.com/shivammathur/setup-php/blob/6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d/README.md#force-update-setup
update: 'true'
# https://github.com/shivammathur/setup-php/blob/6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d/README.md#cache-composer-dependencies
# https://github.com/shivammathur/setup-php/blob/6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d/README.md#problem-matchers
- run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
working-directory: be
shell: bash
- id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
# https://github.com/shivammathur/setup-php/blob/6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d/README.md#cache-composer-dependencies
# https://github.com/actions/cache/blob/a2ed59d39b352305bdd2f628719a53b2cc4f9613/examples.md#php---composer
- id: get-composer-cache-dir
run: echo "path=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
working-directory: be
shell: bash
- uses: actions/cache@v4
- id: cache-restore
uses: actions/cache/restore@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('be/composer.lock') }}
path: ${{ steps.get-composer-cache-dir.outputs.path }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- run: composer install --prefer-dist
working-directory: be
shell: bash
# https://github.com/actions/runner/issues/1478
# https://github.com/actions/setup-node/issues/410#issuecomment-1939482965
- uses: actions/cache/save@v4
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
with:
path: ${{ steps.get-composer-cache-dir.outputs.path }}
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
21 changes: 18 additions & 3 deletions .github/actions/c#/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,27 @@ runs:
- uses: actions/setup-dotnet@v4
with: # https://github.com/actions/setup-dotnet/tree/v4
dotnet-version: 7
cache: true
# https://github.com/actions/setup-node/issues/624#issuecomment-1328681525
cache-dependency-path: ${{ github.workspace }}/c#/*/packages.lock.json
# cache: true
# # https://github.com/actions/setup-node/issues/624#issuecomment-1328681525
# cache-dependency-path: ${{ github.workspace }}/c#/*/packages.lock.json
# in favor of https://github.com/actions/cache/blob/a2ed59d39b352305bdd2f628719a53b2cc4f9613/examples.md#c---nuget
# to allow saving cache even jobs failed
- id: cache-restore
uses: actions/cache/restore@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-
- run: dotnet new globaljson --sdk-version 7.0.405
working-directory: c#
shell: bash
- run: dotnet restore
working-directory: c#
shell: bash
# https://github.com/actions/runner/issues/1478
# https://github.com/actions/setup-node/issues/410#issuecomment-1939482965
- uses: actions/cache/save@v4
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
with:
path: ~/.nuget/packages
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
28 changes: 23 additions & 5 deletions .github/actions/fe/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,28 @@ runs:
- uses: actions/setup-node@v4
with: # https://github.com/actions/setup-node/tree/v4
node-version: lts/*
cache: yarn
# https://github.com/actions/setup-node/issues/624#issuecomment-1328681525
cache-dependency-path: ${{ github.workspace }}/fe/yarn.lock
- name: install
run: yarn install --immutable
# cache: yarn
# # https://github.com/actions/setup-node/issues/624#issuecomment-1328681525
# cache-dependency-path: ${{ github.workspace }}/fe/yarn.lock
# in favor of https://github.com/actions/cache/blob/a2ed59d39b352305bdd2f628719a53b2cc4f9613/examples.md#node---yarn-2
# to allow saving cache even jobs failed
- id: get-yarn-cache-dir
run: echo "path=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
working-directory: fe
shell: bash
- id: cache-restore
uses: actions/cache/restore@v4
with:
path: ${{ steps.get-yarn-cache-dir.outputs.path }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- run: yarn install --immutable
working-directory: fe
shell: bash
# https://github.com/actions/runner/issues/1478
# https://github.com/actions/setup-node/issues/410#issuecomment-1939482965
- uses: actions/cache/save@v4
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
with:
path: ${{ steps.get-yarn-cache-dir.outputs.path }}
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
2 changes: 1 addition & 1 deletion .github/workflows/fe.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: fe
on:
push:
paths: [fe/**]
#paths: [fe/**]
defaults:
run:
working-directory: fe
Expand Down

0 comments on commit 96955ac

Please sign in to comment.