|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + container: discourse/discourse_test:slim-browsers |
| 13 | + timeout-minutes: 30 |
| 14 | + |
| 15 | + env: |
| 16 | + DISCOURSE_HOSTNAME: www.example.com |
| 17 | + RUBY_GLOBAL_METHOD_CACHE_SIZE: 131072 |
| 18 | + RAILS_ENV: development |
| 19 | + QUNIT_RAILS_ENV: development |
| 20 | + PGHOST: postgres |
| 21 | + PGUSER: discourse |
| 22 | + PGPASSWORD: discourse |
| 23 | + |
| 24 | + services: |
| 25 | + postgres: |
| 26 | + image: postgres:13 |
| 27 | + ports: |
| 28 | + - 5432:5432 |
| 29 | + env: |
| 30 | + POSTGRES_USER: discourse |
| 31 | + POSTGRES_PASSWORD: discourse |
| 32 | + options: >- |
| 33 | + --mount type=tmpfs,destination=/var/lib/postgresql/data |
| 34 | + --health-cmd pg_isready |
| 35 | + --health-interval 10s |
| 36 | + --health-timeout 5s |
| 37 | + --health-retries 5 |
| 38 | +
|
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v2 |
| 41 | + with: |
| 42 | + repository: discourse/discourse |
| 43 | + fetch-depth: 1 |
| 44 | + |
| 45 | + - name: Install component |
| 46 | + uses: actions/checkout@v2 |
| 47 | + with: |
| 48 | + path: tmp/component |
| 49 | + fetch-depth: 1 |
| 50 | + |
| 51 | + - name: Setup Git |
| 52 | + run: | |
| 53 | + git config --global user.email "[email protected]" |
| 54 | + git config --global user.name "Discourse CI" |
| 55 | +
|
| 56 | + - name: Start redis |
| 57 | + run: | |
| 58 | + redis-server /etc/redis/redis.conf & |
| 59 | +
|
| 60 | + - name: Start Postgres |
| 61 | + run: | |
| 62 | + chown -R postgres /var/run/postgresql |
| 63 | + sudo -E -u postgres script/start_test_db.rb |
| 64 | + sudo -u postgres psql -c "CREATE ROLE $PGUSER LOGIN SUPERUSER PASSWORD '$PGPASSWORD';" |
| 65 | +
|
| 66 | + - name: Bundler cache |
| 67 | + uses: actions/cache@v2 |
| 68 | + with: |
| 69 | + path: vendor/bundle |
| 70 | + key: ${{ runner.os }}-2.7-gem-${{ hashFiles('**/Gemfile.lock') }} |
| 71 | + restore-keys: | |
| 72 | + ${{ runner.os }}-2.7-gem- |
| 73 | +
|
| 74 | + - name: Setup gems |
| 75 | + run: | |
| 76 | + bundle config --local path vendor/bundle |
| 77 | + bundle config --local deployment true |
| 78 | + bundle config --local without development |
| 79 | + bundle install --jobs 4 |
| 80 | + bundle clean |
| 81 | +
|
| 82 | + - name: Get yarn cache directory |
| 83 | + id: yarn-cache-dir |
| 84 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 85 | + |
| 86 | + - name: Yarn cache |
| 87 | + uses: actions/cache@v2 |
| 88 | + id: yarn-cache |
| 89 | + with: |
| 90 | + path: ${{ steps.yarn-cache-dir.outputs.dir }} |
| 91 | + key: ${{ runner.os }}-${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 92 | + restore-keys: | |
| 93 | + ${{ runner.os }}-${{ matrix.os }}-yarn- |
| 94 | +
|
| 95 | + - name: Yarn install |
| 96 | + run: yarn install |
| 97 | + |
| 98 | + - name: Migrate database |
| 99 | + run: | |
| 100 | + bin/rake db:create |
| 101 | + bin/rake db:migrate |
| 102 | +
|
| 103 | + - name: Check qunit existence |
| 104 | + id: check_qunit |
| 105 | + shell: bash |
| 106 | + run: | |
| 107 | + shopt -s extglob |
| 108 | + if ls tmp/component/test/**/*.@(js|es6) &> /dev/null; then |
| 109 | + echo "::set-output name=files_exist::true" |
| 110 | + fi |
| 111 | +
|
| 112 | + - name: Component QUnit |
| 113 | + if: steps.check_qunit.outputs.files_exist == 'true' |
| 114 | + run: | |
| 115 | + bundle exec rake themes:install -- '--{"${{ github.event.repository.name }}": "tmp/component"}' |
| 116 | + UNICORN_TIMEOUT=120 bundle exec rake themes:qunit[name,${{ github.event.repository.name }}] |
| 117 | + timeout-minutes: 10 |
| 118 | + |
| 119 | + - name: Lint English locale |
| 120 | + if: ${{ always() }} |
| 121 | + run: bundle exec ruby script/i18n_lint.rb "tmp/component/locales/en.yml" |
0 commit comments