DEV: Update CI workflows (#179)
Co-authored-by: CvX <CvX@users.noreply.github.com>
This commit is contained in:
parent
4bb06f0e16
commit
6f50e26335
|
@ -3,7 +3,6 @@ name: Linting
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
|
||||||
- main
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
|
@ -15,9 +14,13 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 12
|
node-version: 16
|
||||||
|
cache: yarn
|
||||||
|
|
||||||
|
- name: Yarn install
|
||||||
|
run: yarn install
|
||||||
|
|
||||||
- name: Set up ruby
|
- name: Set up ruby
|
||||||
uses: ruby/setup-ruby@v1
|
uses: ruby/setup-ruby@v1
|
||||||
|
@ -25,9 +28,6 @@ jobs:
|
||||||
ruby-version: 2.7
|
ruby-version: 2.7
|
||||||
bundler-cache: true
|
bundler-cache: true
|
||||||
|
|
||||||
- name: Yarn install
|
|
||||||
run: yarn install
|
|
||||||
|
|
||||||
- name: ESLint
|
- name: ESLint
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern {test,assets}/javascripts
|
run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern {test,assets}/javascripts
|
||||||
|
|
|
@ -3,7 +3,6 @@ name: Plugin Tests
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
|
||||||
- main
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
|
@ -11,14 +10,13 @@ jobs:
|
||||||
build:
|
build:
|
||||||
name: ${{ matrix.build_type }}
|
name: ${{ matrix.build_type }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: discourse/discourse_test:release
|
container: discourse/discourse_test:slim${{ matrix.build_type == 'frontend' && '-browsers' || '' }}
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DISCOURSE_HOSTNAME: www.example.com
|
DISCOURSE_HOSTNAME: www.example.com
|
||||||
RUBY_GLOBAL_METHOD_CACHE_SIZE: 131072
|
RUBY_GLOBAL_METHOD_CACHE_SIZE: 131072
|
||||||
RAILS_ENV: test
|
RAILS_ENV: test
|
||||||
PGHOST: postgres
|
|
||||||
PGUSER: discourse
|
PGUSER: discourse
|
||||||
PGPASSWORD: discourse
|
PGPASSWORD: discourse
|
||||||
|
|
||||||
|
@ -27,23 +25,6 @@ jobs:
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
build_type: ["backend", "frontend"]
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
@ -66,13 +47,19 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
redis-server /etc/redis/redis.conf &
|
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
|
- name: Bundler cache
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: vendor/bundle
|
path: vendor/bundle
|
||||||
key: ${{ runner.os }}-${{ matrix.ruby }}-gem-${{ hashFiles('**/Gemfile.lock') }}
|
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-${{ matrix.ruby }}-gem-
|
${{ runner.os }}-gem-
|
||||||
|
|
||||||
- name: Setup gems
|
- name: Setup gems
|
||||||
run: |
|
run: |
|
||||||
|
@ -95,18 +82,47 @@ jobs:
|
||||||
id: yarn-cache
|
id: yarn-cache
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache-dir.outputs.dir }}
|
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: |
|
restore-keys: |
|
||||||
${{ runner.os }}-${{ matrix.os }}-yarn-
|
${{ runner.os }}-yarn-
|
||||||
|
|
||||||
- name: Yarn install
|
- name: Yarn install
|
||||||
run: 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: |
|
run: |
|
||||||
bin/rake db:create
|
bin/rake db:create
|
||||||
bin/rake db:migrate
|
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
|
- name: Check spec existence
|
||||||
id: check_spec
|
id: check_spec
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
Loading…
Reference in New Issue