Add caching in CI
This commit is contained in:
+51
-2
@@ -59,6 +59,40 @@ jobs:
|
||||
- name: Install plugin
|
||||
run: cp -r plugin core/plugins/hledger
|
||||
|
||||
- name: Container envs
|
||||
id: container-envs
|
||||
run: |
|
||||
echo "ruby_version=$RUBY_VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "debian_release=$DEBIAN_RELEASE" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Bundler cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: core/vendor/bundle
|
||||
key: ${{ runner.os }}-${{ steps.container-envs.outputs.ruby_version }}-${{ steps.container-envs.outputs.debian_release }}-gems-${{ hashFiles('core/Gemfile.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-${{ steps.container-envs.outputs.ruby_version }}-${{ steps.container-envs.outputs.debian_release }}-gems-
|
||||
|
||||
- name: Get pnpm store directory
|
||||
id: pnpm-store
|
||||
working-directory: core
|
||||
run: echo "dir=$(pnpm store path)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: pnpm cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.pnpm-store.outputs.dir }}
|
||||
key: ${{ runner.os }}-pnpm-${{ hashFiles('core/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-
|
||||
|
||||
- name: App state cache
|
||||
id: app-cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: core/tmp/app-cache
|
||||
key: ${{ runner.os }}-app-v1-${{ hashFiles('core/db/**/*', 'core/plugins/hledger/db/**/*', 'plugin/.gitea/workflows/ci.yml') }}
|
||||
|
||||
- name: Install hledger
|
||||
run: |
|
||||
apt-get update
|
||||
@@ -77,17 +111,32 @@ jobs:
|
||||
|
||||
- name: Setup gems
|
||||
working-directory: core
|
||||
run: bundle install
|
||||
run: |
|
||||
bundle config set --local path vendor/bundle
|
||||
bundle config set --local without development
|
||||
bundle config set --local deployment true
|
||||
bundle install
|
||||
|
||||
- name: Install JS dependencies
|
||||
working-directory: core
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Prepare database
|
||||
- name: Restore database from cache
|
||||
if: steps.app-cache.outputs.cache-hit == 'true'
|
||||
working-directory: core
|
||||
run: |
|
||||
psql -f tmp/app-cache/cache.sql postgres
|
||||
rm -rf public/uploads && cp -r tmp/app-cache/uploads public/uploads
|
||||
|
||||
- name: Create and migrate database
|
||||
if: steps.app-cache.outputs.cache-hit != 'true'
|
||||
working-directory: core
|
||||
run: |
|
||||
bin/rake db:create
|
||||
bin/rake db:migrate
|
||||
mkdir -p tmp/app-cache
|
||||
pg_dumpall > tmp/app-cache/cache.sql
|
||||
rm -rf tmp/app-cache/uploads && cp -r public/uploads tmp/app-cache/uploads
|
||||
|
||||
- name: Plugin RSpec
|
||||
working-directory: core
|
||||
|
||||
Reference in New Issue
Block a user