Skip to content

DEV: Update CI workflows #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/plugin-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Linting
on:
push:
branches:
- master
- main
pull_request:

Expand All @@ -15,19 +14,20 @@ 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
with:
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
Expand Down
66 changes: 41 additions & 25 deletions .github/workflows/plugin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ name: Plugin Tests
on:
push:
branches:
- master
- main
pull_request:

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

Expand All @@ -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
Expand All @@ -65,14 +46,20 @@ jobs:
- name: Start redis
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: |
Expand All @@ -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
Expand Down