DEV: Update CI workflows (#11)
Co-authored-by: CvX <CvX@users.noreply.github.com>
This commit is contained in:
parent
6a4c6a901c
commit
d3cf17a4a9
|
@ -3,7 +3,6 @@ name: Linting
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
|
@ -15,9 +14,13 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v1
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 12
|
||||
node-version: 16
|
||||
cache: yarn
|
||||
|
||||
- name: Yarn install
|
||||
run: yarn install
|
||||
|
||||
- name: Set up ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
|
@ -25,9 +28,6 @@ jobs:
|
|||
ruby-version: 2.7
|
||||
bundler-cache: true
|
||||
|
||||
- name: Yarn install
|
||||
run: yarn install
|
||||
|
||||
- name: ESLint
|
||||
if: ${{ always() }}
|
||||
run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern {test,assets}/javascripts
|
||||
|
|
|
@ -3,7 +3,6 @@ name: Plugin Tests
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
|
@ -11,14 +10,13 @@ jobs:
|
|||
build:
|
||||
name: ${{ matrix.build_type }}
|
||||
runs-on: ubuntu-latest
|
||||
container: discourse/discourse_test:release
|
||||
container: discourse/discourse_test:slim${{ matrix.build_type == 'frontend' && '-browsers' || '' }}
|
||||
timeout-minutes: 60
|
||||
|
||||
env:
|
||||
DISCOURSE_HOSTNAME: www.example.com
|
||||
RUBY_GLOBAL_METHOD_CACHE_SIZE: 131072
|
||||
RAILS_ENV: test
|
||||
PGHOST: postgres
|
||||
PGUSER: discourse
|
||||
PGPASSWORD: discourse
|
||||
|
||||
|
@ -27,23 +25,6 @@ jobs:
|
|||
|
||||
matrix:
|
||||
build_type: ["backend", "frontend"]
|
||||
ruby: ["2.7"]
|
||||
postgres: ["13"]
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:${{ matrix.postgres }}
|
||||
ports:
|
||||
- 5432:5432
|
||||
env:
|
||||
POSTGRES_USER: discourse
|
||||
POSTGRES_PASSWORD: discourse
|
||||
options: >-
|
||||
--mount type=tmpfs,destination=/var/lib/postgresql/data
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
@ -66,13 +47,19 @@ jobs:
|
|||
run: |
|
||||
redis-server /etc/redis/redis.conf &
|
||||
|
||||
- name: Start Postgres
|
||||
run: |
|
||||
chown -R postgres /var/run/postgresql
|
||||
sudo -E -u postgres script/start_test_db.rb
|
||||
sudo -u postgres psql -c "CREATE ROLE $PGUSER LOGIN SUPERUSER PASSWORD '$PGPASSWORD';"
|
||||
|
||||
- name: Bundler cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: vendor/bundle
|
||||
key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }}
|
||||
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-${{ matrix.ruby }}-gem-
|
||||
${{ runner.os }}-gem-
|
||||
|
||||
- name: Setup gems
|
||||
run: |
|
||||
|
@ -95,18 +82,47 @@ jobs:
|
|||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir.outputs.dir }}
|
||||
key: ${{ runner.os }}-${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-${{ matrix.os }}-yarn-
|
||||
${{ runner.os }}-yarn-
|
||||
|
||||
- name: Yarn install
|
||||
run: yarn install
|
||||
|
||||
- name: Migrate database
|
||||
- name: Fetch app state cache
|
||||
uses: actions/cache@v2
|
||||
id: app-cache
|
||||
with:
|
||||
path: tmp/app-cache
|
||||
key: >- # postgres version, hash of migrations, "parallel?"
|
||||
${{ runner.os }}-
|
||||
${{ hashFiles('.github/workflows/tests.yml') }}-
|
||||
${{ matrix.postgres }}-
|
||||
${{ hashFiles('db/**/*', 'plugins/**/db/**/*') }}-
|
||||
${{ env.USES_PARALLEL_DATABASES }}
|
||||
|
||||
- name: Restore database from cache
|
||||
if: steps.app-cache.outputs.cache-hit == 'true'
|
||||
run: psql -f tmp/app-cache/cache.sql postgres
|
||||
|
||||
- name: Restore uploads from cache
|
||||
if: steps.app-cache.outputs.cache-hit == 'true'
|
||||
run: 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'
|
||||
run: |
|
||||
bin/rake db:create
|
||||
bin/rake db:migrate
|
||||
|
||||
- name: Dump database for cache
|
||||
if: steps.app-cache.outputs.cache-hit != 'true'
|
||||
run: mkdir -p tmp/app-cache && pg_dumpall > tmp/app-cache/cache.sql
|
||||
|
||||
- name: Dump uploads for cache
|
||||
if: steps.app-cache.outputs.cache-hit != 'true'
|
||||
run: rm -rf tmp/app-cache/uploads && cp -r public/uploads tmp/app-cache/uploads
|
||||
|
||||
- name: Check spec existence
|
||||
id: check_spec
|
||||
shell: bash
|
||||
|
|
Loading…
Reference in New Issue