2020-02-24 23:05:19 +03:00
|
|
|
name: Test Suite
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
2021-02-02 21:04:07 +03:00
|
|
|
- main
|
2022-07-19 16:19:08 +03:00
|
|
|
- 'v5.*'
|
2021-02-02 21:04:07 +03:00
|
|
|
- 3.x
|
2020-02-24 23:05:19 +03:00
|
|
|
- 2.x
|
2020-03-25 20:18:18 +03:00
|
|
|
- 'renovate/*'
|
2020-04-16 13:01:27 +03:00
|
|
|
env:
|
|
|
|
FORCE_COLOR: 1
|
2022-01-14 13:21:42 +03:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.head_ref || github.run_id }}
|
|
|
|
cancel-in-progress: true
|
2020-02-24 23:05:19 +03:00
|
|
|
jobs:
|
2020-10-28 11:05:50 +03:00
|
|
|
lint:
|
|
|
|
runs-on: ubuntu-18.04
|
|
|
|
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/'))
|
|
|
|
name: Lint
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2021-02-09 19:21:54 +03:00
|
|
|
- uses: actions/setup-node@v2
|
2021-11-25 11:07:45 +03:00
|
|
|
env:
|
|
|
|
FORCE_COLOR: 0
|
2020-10-28 11:05:50 +03:00
|
|
|
with:
|
2021-10-26 22:12:37 +03:00
|
|
|
node-version: '14.17.0'
|
2021-11-30 11:01:22 +03:00
|
|
|
cache: yarn
|
2020-10-28 11:05:50 +03:00
|
|
|
- run: yarn
|
|
|
|
- run: yarn lint
|
|
|
|
- uses: daniellockyer/action-slack-build@master
|
2021-02-02 21:04:07 +03:00
|
|
|
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main'
|
2020-10-28 11:05:50 +03:00
|
|
|
with:
|
|
|
|
status: ${{ job.status }}
|
|
|
|
env:
|
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
|
|
|
2020-11-05 15:58:01 +03:00
|
|
|
migrations:
|
|
|
|
runs-on: ubuntu-18.04
|
2022-07-20 17:10:38 +03:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ghost/core
|
2020-11-05 15:58:01 +03:00
|
|
|
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/'))
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-01-17 14:05:09 +03:00
|
|
|
env:
|
|
|
|
- DB: sqlite3
|
|
|
|
DB_CLIENT: sqlite3
|
|
|
|
- DB: mysql5
|
|
|
|
DB_CLIENT: mysql
|
|
|
|
- DB: mysql8
|
|
|
|
DB_CLIENT: mysql
|
2020-11-05 15:58:01 +03:00
|
|
|
env:
|
2022-01-17 14:05:09 +03:00
|
|
|
database__client: ${{ matrix.env.DB_CLIENT }}
|
2022-02-16 20:53:07 +03:00
|
|
|
name: Migrations (${{ matrix.env.DB }})
|
2020-11-05 15:58:01 +03:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2020-11-17 12:16:03 +03:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
submodules: true
|
2021-02-09 19:21:54 +03:00
|
|
|
- uses: actions/setup-node@v2
|
2021-11-25 11:07:45 +03:00
|
|
|
env:
|
|
|
|
FORCE_COLOR: 0
|
2020-11-05 15:58:01 +03:00
|
|
|
with:
|
2021-10-26 22:12:37 +03:00
|
|
|
node-version: '14.17.0'
|
2021-11-30 11:01:22 +03:00
|
|
|
cache: yarn
|
2020-11-05 15:58:01 +03:00
|
|
|
|
|
|
|
- name: Shutdown MySQL
|
|
|
|
run: sudo service mysql stop
|
2022-01-17 14:05:09 +03:00
|
|
|
if: matrix.env.DB == 'mysql5' || matrix.env.DB == 'mysql8'
|
2020-11-05 15:58:01 +03:00
|
|
|
|
2022-01-17 14:05:09 +03:00
|
|
|
- uses: daniellockyer/mysql-action@main
|
|
|
|
if: matrix.env.DB == 'mysql5'
|
2020-11-05 15:58:01 +03:00
|
|
|
with:
|
|
|
|
mysql version: '5.7'
|
|
|
|
mysql database: 'ghost_testing'
|
|
|
|
mysql root password: 'root'
|
|
|
|
|
2022-01-17 14:05:09 +03:00
|
|
|
- uses: daniellockyer/mysql-action@main
|
|
|
|
if: matrix.env.DB == 'mysql8'
|
|
|
|
with:
|
2022-03-02 18:13:03 +03:00
|
|
|
authentication plugin: 'caching_sha2_password'
|
2022-01-17 14:05:09 +03:00
|
|
|
mysql version: '8.0'
|
|
|
|
mysql database: 'ghost_testing'
|
|
|
|
mysql root password: 'root'
|
|
|
|
|
2022-06-02 14:23:17 +03:00
|
|
|
- name: Set env vars (SQLite)
|
|
|
|
if: contains(matrix.env.DB, 'sqlite')
|
|
|
|
run: echo "database__connection__filename=/dev/shm/ghost-test.db" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Set env vars (MySQL)
|
|
|
|
if: contains(matrix.env.DB, 'mysql')
|
|
|
|
run: |
|
|
|
|
echo "database__connection__host=127.0.0.1" >> $GITHUB_ENV
|
|
|
|
echo "database__connection__user=root" >> $GITHUB_ENV
|
|
|
|
echo "database__connection__password=root" >> $GITHUB_ENV
|
|
|
|
echo "database__connection__database=ghost_testing" >> $GITHUB_ENV
|
|
|
|
|
2020-11-05 15:58:01 +03:00
|
|
|
- run: yarn
|
2020-11-11 13:33:18 +03:00
|
|
|
- run: |
|
|
|
|
node index.js &
|
2020-11-20 11:41:59 +03:00
|
|
|
sleep 20 && { kill $! && wait $!; } 2>/dev/null
|
2021-02-02 13:24:49 +03:00
|
|
|
|
2022-05-09 13:22:03 +03:00
|
|
|
- run: sqlite3 ${{ env.database__connection__filename }} "DELETE FROM migrations WHERE version LIKE '5.%';"
|
|
|
|
if: matrix.env.DB == 'sqlite3'
|
|
|
|
- run: mysql -h127.0.0.1 -uroot -proot ghost_testing -e "DELETE FROM migrations WHERE version LIKE '5.%';"
|
|
|
|
if: matrix.env.DB == 'mysql5' || matrix.env.DB == 'mysql8'
|
|
|
|
|
2020-11-05 15:58:01 +03:00
|
|
|
- run: yarn knex-migrator migrate --force
|
|
|
|
|
2022-02-16 20:50:56 +03:00
|
|
|
unit-tests:
|
|
|
|
runs-on: ubuntu-18.04
|
|
|
|
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/'))
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-04-19 17:53:44 +03:00
|
|
|
node: [ '14.17.0', '16.13.0' ]
|
2022-02-16 20:50:56 +03:00
|
|
|
name: Unit Tests (Node ${{ matrix.node }})
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-node@v2
|
|
|
|
env:
|
|
|
|
FORCE_COLOR: 0
|
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node }}
|
|
|
|
cache: yarn
|
|
|
|
|
|
|
|
- run: yarn
|
2022-07-20 18:43:55 +03:00
|
|
|
- run: yarn test
|
2022-02-16 20:50:56 +03:00
|
|
|
|
|
|
|
- uses: codecov/codecov-action@v2
|
|
|
|
|
|
|
|
- uses: daniellockyer/action-slack-build@master
|
|
|
|
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
with:
|
|
|
|
status: ${{ job.status }}
|
|
|
|
env:
|
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
|
|
|
|
|
|
database-tests:
|
2020-08-18 15:05:15 +03:00
|
|
|
runs-on: ubuntu-18.04
|
2022-07-20 17:10:38 +03:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ghost/core
|
2020-03-25 20:18:18 +03:00
|
|
|
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/'))
|
2020-02-24 23:05:19 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-04-19 17:53:44 +03:00
|
|
|
node: [ '14.17.0', '16.13.0' ]
|
2020-02-24 23:05:19 +03:00
|
|
|
env:
|
|
|
|
- DB: sqlite3
|
|
|
|
NODE_ENV: testing
|
2022-01-17 14:05:09 +03:00
|
|
|
- DB: mysql5
|
|
|
|
NODE_ENV: testing-mysql
|
|
|
|
- DB: mysql8
|
2020-02-24 23:05:19 +03:00
|
|
|
NODE_ENV: testing-mysql
|
|
|
|
env:
|
|
|
|
DB: ${{ matrix.env.DB }}
|
|
|
|
NODE_ENV: ${{ matrix.env.NODE_ENV }}
|
2022-02-16 20:53:07 +03:00
|
|
|
name: Database Tests (Node ${{ matrix.node }}, ${{ matrix.env.DB }})
|
2020-02-24 23:05:19 +03:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2021-02-09 19:21:54 +03:00
|
|
|
- uses: actions/setup-node@v2
|
2021-11-25 11:07:45 +03:00
|
|
|
env:
|
|
|
|
FORCE_COLOR: 0
|
2020-02-24 23:05:19 +03:00
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node }}
|
2021-11-30 11:01:22 +03:00
|
|
|
cache: yarn
|
2020-03-19 22:19:00 +03:00
|
|
|
|
2020-03-20 14:05:16 +03:00
|
|
|
- name: Shutdown MySQL
|
|
|
|
run: sudo service mysql stop
|
2022-01-17 14:05:09 +03:00
|
|
|
if: matrix.env.DB == 'mysql5' || matrix.env.DB == 'mysql8'
|
2020-03-20 14:05:16 +03:00
|
|
|
|
2022-01-17 14:05:09 +03:00
|
|
|
- uses: daniellockyer/mysql-action@main
|
|
|
|
if: matrix.env.DB == 'mysql5'
|
2020-03-20 14:05:16 +03:00
|
|
|
with:
|
|
|
|
mysql version: '5.7'
|
|
|
|
mysql database: 'ghost_testing'
|
|
|
|
mysql root password: 'root'
|
|
|
|
|
2022-01-17 14:05:09 +03:00
|
|
|
- uses: daniellockyer/mysql-action@main
|
|
|
|
if: matrix.env.DB == 'mysql8'
|
|
|
|
with:
|
2022-03-02 18:13:03 +03:00
|
|
|
authentication plugin: 'caching_sha2_password'
|
2022-01-17 14:05:09 +03:00
|
|
|
mysql version: '8.0'
|
|
|
|
mysql database: 'ghost_testing'
|
|
|
|
mysql root password: 'root'
|
|
|
|
|
2020-02-24 23:05:19 +03:00
|
|
|
- run: yarn
|
2021-11-11 12:26:11 +03:00
|
|
|
|
|
|
|
- run: date +%s > ${{ runner.temp }}/startTime # Get start time for test suite
|
|
|
|
|
2022-06-02 14:23:17 +03:00
|
|
|
- name: Set env vars (SQLite)
|
|
|
|
if: contains(matrix.env.DB, 'sqlite')
|
|
|
|
run: echo "database__connection__filename=/dev/shm/ghost-test.db" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Set env vars (MySQL)
|
|
|
|
if: contains(matrix.env.DB, 'mysql')
|
|
|
|
run: echo "database__connection__password=root" >> $GITHUB_ENV
|
|
|
|
|
2022-02-16 20:54:12 +03:00
|
|
|
- name: Run tests
|
|
|
|
run: yarn test:ci
|
2020-04-16 09:36:15 +03:00
|
|
|
|
2021-11-11 12:26:11 +03:00
|
|
|
# Get runtime in seconds for test suite
|
|
|
|
- run: |
|
|
|
|
startTime="$(cat ${{ runner.temp }}/startTime)"
|
|
|
|
endTime="$(date +%s)"
|
|
|
|
echo "test_time=$(($endTime-$startTime))" >> $GITHUB_ENV
|
|
|
|
|
2021-12-14 12:37:38 +03:00
|
|
|
# Continue on error if TailScale service is down
|
2021-11-11 12:26:11 +03:00
|
|
|
- name: Tailscale Action
|
2021-12-14 12:37:38 +03:00
|
|
|
timeout-minutes: 2
|
|
|
|
continue-on-error: true
|
2021-12-06 15:40:05 +03:00
|
|
|
if: (github.event_name == 'push' && github.repository_owner == 'TryGhost') || (github.event_name == 'pull_request' && startsWith(github.head_ref, 'TryGhost/'))
|
2021-11-11 12:26:11 +03:00
|
|
|
uses: tailscale/github-action@v1
|
|
|
|
with:
|
|
|
|
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
|
|
|
|
|
|
|
|
# Report time taken to metrics service
|
2021-12-14 12:37:38 +03:00
|
|
|
# Continue on error if previous TailScale step fails
|
2021-11-11 12:26:11 +03:00
|
|
|
- uses: sam-lord/action-trigger-metric@main
|
2021-12-14 12:37:38 +03:00
|
|
|
timeout-minutes: 1
|
|
|
|
continue-on-error: true
|
2021-12-06 15:40:05 +03:00
|
|
|
if: (github.event_name == 'push' && github.repository_owner == 'TryGhost') || (github.event_name == 'pull_request' && startsWith(github.head_ref, 'TryGhost/'))
|
2021-11-11 12:26:11 +03:00
|
|
|
with:
|
|
|
|
metricName: 'test-time'
|
|
|
|
metricValue: ${{ env.test_time }}
|
|
|
|
configuration: |
|
|
|
|
{
|
|
|
|
"metrics": {
|
|
|
|
"transports": ["elasticsearch"],
|
|
|
|
"metadata": {
|
|
|
|
"database": "${{ matrix.env.DB }}",
|
|
|
|
"node": "${{ matrix.node }}"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"elasticsearch": {
|
|
|
|
"host": "${{ secrets.ELASTICSEARCH_HOST }}",
|
|
|
|
"username": "${{ secrets.ELASTICSEARCH_USERNAME }}",
|
|
|
|
"password": "${{ secrets.ELASTICSEARCH_PASSWORD }}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-10 10:58:35 +03:00
|
|
|
- uses: daniellockyer/action-slack-build@master
|
2021-02-02 21:04:07 +03:00
|
|
|
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main'
|
2020-06-10 10:58:35 +03:00
|
|
|
with:
|
|
|
|
status: ${{ job.status }}
|
|
|
|
env:
|
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
2020-06-09 15:21:43 +03:00
|
|
|
|
2020-04-16 09:36:15 +03:00
|
|
|
ghost-cli:
|
|
|
|
name: Ghost-CLI
|
2022-07-22 13:20:40 +03:00
|
|
|
if: false
|
2020-08-18 15:05:15 +03:00
|
|
|
runs-on: ubuntu-18.04
|
2022-07-20 17:10:38 +03:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ghost/core
|
2020-04-16 09:36:15 +03:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
submodules: true
|
2021-02-09 19:21:54 +03:00
|
|
|
- uses: actions/setup-node@v2
|
2021-11-25 11:07:45 +03:00
|
|
|
env:
|
|
|
|
FORCE_COLOR: 0
|
2020-04-16 09:36:15 +03:00
|
|
|
with:
|
2022-04-19 17:29:50 +03:00
|
|
|
node-version: '14.17.0'
|
2021-11-30 11:01:22 +03:00
|
|
|
cache: yarn
|
2020-05-28 14:59:08 +03:00
|
|
|
- run: npm install -g ghost-cli@latest
|
2022-05-24 10:20:57 +03:00
|
|
|
- run: npm --no-git-tag-version version minor # We need to artificially bump the minor version to get migrations to run
|
2021-03-01 11:56:27 +03:00
|
|
|
|
2020-04-16 09:36:15 +03:00
|
|
|
- run: zip -r ghost.zip .
|
|
|
|
|
|
|
|
- name: Clean Install
|
|
|
|
run: |
|
|
|
|
DIR=$(mktemp -d)
|
2022-07-20 17:10:38 +03:00
|
|
|
ghost install local -d $DIR --zip $(pwd)/ghost.zip
|
2020-04-16 09:36:15 +03:00
|
|
|
|
2021-02-09 19:18:40 +03:00
|
|
|
- name: Latest Release
|
|
|
|
run: |
|
|
|
|
DIR=$(mktemp -d)
|
|
|
|
ghost install local -d $DIR
|
2022-07-20 17:10:38 +03:00
|
|
|
ghost update -d $DIR --zip $(pwd)/ghost.zip
|
2021-02-09 19:18:40 +03:00
|
|
|
|
2021-03-17 14:47:27 +03:00
|
|
|
- name: Update from latest v3
|
|
|
|
run: |
|
|
|
|
DIR=$(mktemp -d)
|
|
|
|
ghost install v3 --local -d $DIR
|
2022-07-20 17:10:38 +03:00
|
|
|
ghost update -f -d $DIR --zip $(pwd)/ghost.zip
|
2021-03-17 14:47:27 +03:00
|
|
|
|
2021-06-09 15:51:55 +03:00
|
|
|
- name: Print debug logs
|
|
|
|
if: failure()
|
2022-02-04 11:40:26 +03:00
|
|
|
run: |
|
|
|
|
[ -f ~/.ghost/logs/*.log ] && cat ~/.ghost/logs/*.log
|
2021-06-09 15:51:55 +03:00
|
|
|
|
2020-06-10 10:58:35 +03:00
|
|
|
- uses: daniellockyer/action-slack-build@master
|
2021-02-02 21:04:07 +03:00
|
|
|
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main'
|
2020-06-10 10:58:35 +03:00
|
|
|
with:
|
|
|
|
status: ${{ job.status }}
|
|
|
|
env:
|
|
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
2021-01-19 15:10:50 +03:00
|
|
|
|
|
|
|
canary:
|
|
|
|
runs-on: ubuntu-18.04
|
2022-07-22 11:36:47 +03:00
|
|
|
needs: [lint, migrations, unit-tests, database-tests]
|
2021-02-02 21:04:07 +03:00
|
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
2021-01-19 15:10:50 +03:00
|
|
|
name: Canary
|
|
|
|
steps:
|
2021-06-01 19:04:16 +03:00
|
|
|
- name: Invoke Canary Build
|
|
|
|
uses: benc-uk/workflow-dispatch@v1
|
2021-01-19 15:10:50 +03:00
|
|
|
with:
|
2021-06-01 19:04:16 +03:00
|
|
|
workflow: Canary Build
|
|
|
|
token: ${{ secrets.RELEASE_TOKEN }}
|