Skip to content
Snippets Groups Projects
Unverified Commit 851f6ceb authored by discoursebot's avatar discoursebot Committed by GitHub
Browse files

DEV: Update CI workflows (#58)


Co-authored-by: default avatarCvX <CvX@users.noreply.github.com>
parent 7792d1eb
No related branches found
No related tags found
No related merge requests found
...@@ -10,14 +10,13 @@ jobs: ...@@ -10,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
...@@ -26,23 +25,7 @@ jobs: ...@@ -26,23 +25,7 @@ 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
with: with:
...@@ -59,16 +42,25 @@ jobs: ...@@ -59,16 +42,25 @@ jobs:
run: | run: |
git config --global user.email "ci@ci.invalid" git config --global user.email "ci@ci.invalid"
git config --global user.name "Discourse CI" git config --global user.name "Discourse CI"
- name: Start redis - name: Start redis
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: |
bundle config --local path vendor/bundle bundle config --local path vendor/bundle
...@@ -76,6 +68,7 @@ jobs: ...@@ -76,6 +68,7 @@ jobs:
bundle config --local without development bundle config --local without development
bundle install --jobs 4 bundle install --jobs 4
bundle clean bundle clean
- name: Lint English locale - name: Lint English locale
if: matrix.build_type == 'backend' if: matrix.build_type == 'backend'
run: bundle exec ruby script/i18n_lint.rb "plugins/${{ github.event.repository.name }}/locales/{client,server}.en.yml" run: bundle exec ruby script/i18n_lint.rb "plugins/${{ github.event.repository.name }}/locales/{client,server}.en.yml"
...@@ -89,16 +82,47 @@ jobs: ...@@ -89,16 +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
...@@ -106,6 +130,7 @@ jobs: ...@@ -106,6 +130,7 @@ jobs:
if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/spec -type f -name "*.rb" 2> /dev/null | wc -l) ]; then if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/spec -type f -name "*.rb" 2> /dev/null | wc -l) ]; then
echo "::set-output name=files_exist::true" echo "::set-output name=files_exist::true"
fi fi
- name: Plugin RSpec - name: Plugin RSpec
if: matrix.build_type == 'backend' && steps.check_spec.outputs.files_exist == 'true' if: matrix.build_type == 'backend' && steps.check_spec.outputs.files_exist == 'true'
run: bin/rake plugin:spec[${{ github.event.repository.name }}] run: bin/rake plugin:spec[${{ github.event.repository.name }}]
...@@ -117,6 +142,7 @@ jobs: ...@@ -117,6 +142,7 @@ jobs:
if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/test/javascripts -type f \( -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/test/javascripts -type f \( -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then
echo "::set-output name=files_exist::true" echo "::set-output name=files_exist::true"
fi fi
- name: Plugin QUnit - name: Plugin QUnit
if: matrix.build_type == 'frontend' && steps.check_qunit.outputs.files_exist == 'true' if: matrix.build_type == 'frontend' && steps.check_qunit.outputs.files_exist == 'true'
run: bundle exec rake plugin:qunit['${{ github.event.repository.name }}','1200000'] run: bundle exec rake plugin:qunit['${{ github.event.repository.name }}','1200000']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment