Skip to content

Commit

Permalink
Merge branch 'main' into i18n_swe_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellockyer authored Nov 20, 2023
2 parents ccd0a9e + e84f792 commit c7cccdd
Show file tree
Hide file tree
Showing 1,145 changed files with 13,873 additions and 40,188 deletions.
5 changes: 0 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,3 @@ Please include a description of your change & check your PR against this list, t
- [ ] The build will pass (run `yarn test:all` and `yarn lint`)

We appreciate your contribution!

---

<!-- Leave the line below if you'd like GitHub Copilot to generate a summary from your commit -->
copilot:summary
7 changes: 7 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'affects:i18n':
- 'ghost/i18n/**'
'affects:admin':
- 'ghost/admin/**'
- 'apps/admin-x-**'
'affects:portal':
- 'apps/portal/**'
36 changes: 24 additions & 12 deletions .github/scripts/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');
const util = require('util');
const exec = util.promisify(require('child_process').exec);

const chalk = require('chalk');
const concurrently = require('concurrently');

// check we're running on Node 18 and above
Expand Down Expand Up @@ -50,26 +51,32 @@ const COMMAND_TYPESCRIPT = {
env: {}
};

const COMMAND_ADMINX = {
const COMMANDS_ADMINX = [{
name: 'adminXDeps',
command: 'nx watch --projects=apps/admin-x-design-system,apps/admin-x-framework -- nx run \\$NX_PROJECT_NAME:build --skip-nx-cache',
cwd: path.resolve(__dirname, '../..'),
prefixColor: '#C35831',
env: {}
}, {
name: 'adminX',
command: 'yarn dev',
command: 'nx run @tryghost/admin-x-settings:build && nx run @tryghost/admin-x-settings:dev',
cwd: path.resolve(__dirname, '../../apps/admin-x-settings'),
prefixColor: '#C35831',
env: {}
};
}];

if (DASH_DASH_ARGS.includes('ghost')) {
commands = [COMMAND_GHOST, COMMAND_TYPESCRIPT];
} else if (DASH_DASH_ARGS.includes('admin')) {
commands = [COMMAND_ADMIN, COMMAND_ADMINX];
commands = [COMMAND_ADMIN, ...COMMANDS_ADMINX];
} else {
commands = [COMMAND_GHOST, COMMAND_TYPESCRIPT, COMMAND_ADMIN, COMMAND_ADMINX];
commands = [COMMAND_GHOST, COMMAND_TYPESCRIPT, COMMAND_ADMIN, ...COMMANDS_ADMINX];
}

if (DASH_DASH_ARGS.includes('portal') || DASH_DASH_ARGS.includes('all')) {
commands.push({
name: 'portal',
command: 'yarn dev',
command: 'nx run @tryghost/portal:dev',
cwd: path.resolve(__dirname, '../../apps/portal'),
prefixColor: 'magenta',
env: {}
Expand All @@ -92,7 +99,7 @@ if (DASH_DASH_ARGS.includes('portal') || DASH_DASH_ARGS.includes('all')) {
if (DASH_DASH_ARGS.includes('signup') || DASH_DASH_ARGS.includes('all')) {
commands.push({
name: 'signup-form',
command: DASH_DASH_ARGS.includes('signup') ? 'yarn dev' : 'yarn preview',
command: DASH_DASH_ARGS.includes('signup') ? 'nx run @tryghost/signup-form:dev' : 'nx run @tryghost/signup-form:preview',
cwd: path.resolve(__dirname, '../../apps/signup-form'),
prefixColor: 'magenta',
env: {}
Expand All @@ -103,7 +110,7 @@ if (DASH_DASH_ARGS.includes('signup') || DASH_DASH_ARGS.includes('all')) {
if (DASH_DASH_ARGS.includes('announcement-bar') || DASH_DASH_ARGS.includes('announcementBar') || DASH_DASH_ARGS.includes('announcementbar') || DASH_DASH_ARGS.includes('all')) {
commands.push({
name: 'announcement-bar',
command: 'yarn dev',
command: 'nx run @tryghost/announcement-bar:dev',
cwd: path.resolve(__dirname, '../../apps/announcement-bar'),
prefixColor: '#DC9D00',
env: {}
Expand All @@ -114,7 +121,7 @@ if (DASH_DASH_ARGS.includes('announcement-bar') || DASH_DASH_ARGS.includes('anno
if (DASH_DASH_ARGS.includes('search') || DASH_DASH_ARGS.includes('all')) {
commands.push({
name: 'search',
command: 'yarn dev',
command: 'nx run @tryghost/sodo-search:dev',
cwd: path.resolve(__dirname, '../../apps/sodo-search'),
prefixColor: '#23de43',
env: {}
Expand Down Expand Up @@ -153,7 +160,7 @@ if (DASH_DASH_ARGS.includes('comments') || DASH_DASH_ARGS.includes('all')) {

commands.push({
name: 'comments',
command: 'yarn dev',
command: 'nx run @tryghost/comments-ui:dev',
cwd: path.resolve(__dirname, '../../apps/comments-ui'),
prefixColor: '#E55137',
env: {}
Expand All @@ -165,7 +172,6 @@ async function handleStripe() {
if (DASH_DASH_ARGS.includes('offline')) {
return;
}
console.log('Fetching Stripe secret token..');

let stripeSecret;
try {
Expand Down Expand Up @@ -198,6 +204,8 @@ async function handleStripe() {
process.exit(0);
}

console.log(`Running projects: ${commands.map(c => chalk.green(c.name)).join(', ')}`);

const {result} = concurrently(commands, {
prefix: 'name',
killOthers: ['failure', 'success']
Expand All @@ -206,6 +214,10 @@ async function handleStripe() {
try {
await result;
} catch (err) {
console.error('\nExecuting dev command failed, ensure dependencies are up-to-date by running `yarn fix`\n');
console.error();
console.error(chalk.red(`Executing dev command failed:`) + `\n`);
console.error(chalk.red(`If you've recently done a \`yarn main\`, dependencies might be out of sync. Try running \`${chalk.green('yarn fix')}\` to fix this.`));
console.error(chalk.red(`If not, something else went wrong. Please report this to the Ghost team.`));
console.error();
}
})();
127 changes: 108 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:
env:
FORCE_COLOR: 1
HEAD_COMMIT: ${{ github.sha }}
GITHUB_CONTEXT: ${{ toJson(github) }}
CACHED_DEPENDENCY_PATHS: |
${{ github.workspace }}/node_modules
${{ github.workspace }}/apps/*/node_modules
Expand Down Expand Up @@ -43,6 +42,11 @@ jobs:
ref: ${{ env.HEAD_COMMIT }}
fetch-depth: 2

- name: Output GitHub context
run: echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJson(github) }}

- name: Get metadata (push)
if: github.event_name == 'push'
run: |
Expand Down Expand Up @@ -167,7 +171,7 @@ jobs:
key: ${{ env.HEAD_COMMIT }}

- name: Set up Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
env:
FORCE_COLOR: 0
with:
Expand All @@ -192,7 +196,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 100
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
env:
FORCE_COLOR: 0
with:
Expand All @@ -217,6 +221,29 @@ jobs:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

job_i18n:
runs-on: ubuntu-latest
needs: [job_get_metadata, job_install_deps]
name: i18n
if: |
needs.job_get_metadata.outputs.changed_comments_ui == 'true'
|| needs.job_get_metadata.outputs.changed_signup_form == 'true'
|| needs.job_get_metadata.outputs.changed_portal == 'true'
|| needs.job_get_metadata.outputs.changed_core == 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "18.12.1"

- name: Restore caches
uses: ./.github/actions/restore-cache
env:
DEPENDENCY_CACHE_KEY: ${{ needs.job_install_deps.outputs.dependency_cache_key }}

- name: Run i18n tests
run: yarn nx run @tryghost/i18n:test

job_admin-tests:
runs-on: ubuntu-latest
needs: [job_get_metadata, job_install_deps]
Expand All @@ -229,7 +256,7 @@ jobs:
COVERAGE: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "18.12.1"

Expand Down Expand Up @@ -264,14 +291,14 @@ jobs:
runs-on:
labels: ubuntu-latest-4-cores
needs: [job_get_metadata, job_install_deps]
if: needs.job_get_metadata.outputs.is_main == 'true' || needs.job_get_metadata.outputs.has_browser_tests_label == 'true'
if: needs.job_get_metadata.outputs.changed_any_code == 'true' && (needs.job_get_metadata.outputs.is_main == 'true' || needs.job_get_metadata.outputs.has_browser_tests_label == 'true')
concurrency:
group: ${{ github.workflow }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
env:
FORCE_COLOR: 0
with:
Expand Down Expand Up @@ -336,6 +363,54 @@ jobs:
path: ghost/core/playwright-report
retention-days: 30

job_perf-tests:
runs-on:
labels: ubuntu-latest-4-cores
needs: [job_get_metadata, job_install_deps]
if: needs.job_get_metadata.outputs.changed_core == 'true' && needs.job_get_metadata.outputs.is_main == 'true'
name: Performance tests
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-node@v4
env:
FORCE_COLOR: 0
with:
node-version: '18.12.1'

- name: Restore caches
uses: ./.github/actions/restore-cache
env:
DEPENDENCY_CACHE_KEY: ${{ needs.job_install_deps.outputs.dependency_cache_key }}

- name: Install hyperfine
run: |
export HYPERFINE_VERSION=1.18.0
wget https://github.com/sharkdp/hyperfine/releases/download/v$HYPERFINE_VERSION/hyperfine-v$HYPERFINE_VERSION-x86_64-unknown-linux-gnu.tar.gz
tar -zxvf hyperfine-v$HYPERFINE_VERSION-x86_64-unknown-linux-gnu.tar.gz
mv hyperfine-v$HYPERFINE_VERSION-x86_64-unknown-linux-gnu/hyperfine /usr/local/bin
chmod +x /usr/local/bin/hyperfine
- name: Run hyperfine on boot
working-directory: ghost/core
run: hyperfine --show-output --warmup 3 'GHOST_CI_SHUTDOWN_AFTER_BOOT=1 node index.js' --export-json boot-perf.json

- name: Convert data
working-directory: ghost/core
run: |
jq '[{ name: "Boot time", unit: "s", value: .results[0].median, range: ((.results[0].max - .results[0].min) | tostring) }]' < boot-perf.json > boot-perf-formatted.json
- name: Run analysis
uses: benchmark-action/github-action-benchmark@v1.18.0
with:
tool: 'customSmallerIsBetter'
output-file-path: ghost/core/boot-perf-formatted.json
benchmark-data-dir-path: ""
gh-repository: github.com/TryGhost/Ghost-Benchmarks
github-token: ${{ secrets.CANARY_DOCKER_BUILD }}
auto-push: true

job_unit-tests:
runs-on: ubuntu-latest
needs: [job_get_metadata, job_install_deps]
Expand All @@ -348,7 +423,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 100
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
env:
FORCE_COLOR: 0
with:
Expand Down Expand Up @@ -395,7 +470,7 @@ jobs:
name: Database tests (Node ${{ matrix.node }}, ${{ matrix.env.DB }})
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
env:
FORCE_COLOR: 0
with:
Expand Down Expand Up @@ -516,7 +591,9 @@ jobs:
name: Regression tests (Node ${{ matrix.node }}, ${{ matrix.env.DB }})
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
submodules: true
- uses: actions/setup-node@v4
env:
FORCE_COLOR: 0
with:
Expand Down Expand Up @@ -567,7 +644,7 @@ jobs:
CI: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
env:
FORCE_COLOR: 0
with:
Expand Down Expand Up @@ -620,7 +697,7 @@ jobs:
CI: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
env:
FORCE_COLOR: 0
with:
Expand Down Expand Up @@ -673,7 +750,7 @@ jobs:
CI: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
env:
FORCE_COLOR: 0
with:
Expand Down Expand Up @@ -727,7 +804,7 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
env:
FORCE_COLOR: 0
with:
Expand All @@ -750,6 +827,22 @@ jobs:
- run: mv ghost-*.tgz ghost.tgz
working-directory: ghost/core

- name: Install latest v4
run: |
DIR=$(mktemp -d)
echo "V4_DIR=$DIR" >> $GITHUB_ENV
ghost install v4 --local -d $DIR
- uses: actions/setup-node@v4
env:
FORCE_COLOR: 0
with:
node-version: '18.12.1'

- name: Update from v4
run: |
ghost update -f -d $V4_DIR --archive $(pwd)/ghost/core/ghost.tgz
- name: Clean Install
run: |
DIR=$(mktemp -d)
Expand All @@ -761,12 +854,6 @@ jobs:
ghost install local -d $DIR
ghost update -d $DIR --archive $(pwd)/ghost/core/ghost.tgz
- name: Update from latest v4
run: |
DIR=$(mktemp -d)
ghost install v4 --local -d $DIR
ghost update -f -d $DIR --archive $(pwd)/ghost/core/ghost.tgz
- name: Print debug logs
if: failure()
run: |
Expand Down Expand Up @@ -832,11 +919,13 @@ jobs:
job_get_metadata,
job_install_deps,
job_lint,
job_i18n,
job_ghost-cli,
job_admin-tests,
job_unit-tests,
job_database-tests,
job_regression-tests,
job_browser-tests,
job_admin_x_settings,
job_comments_ui,
job_signup_form,
Expand Down
Loading

0 comments on commit c7cccdd

Please sign in to comment.