Skip to content

Commit

Permalink
chore: run template tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Leksat committed Oct 17, 2023
1 parent b22387e commit 3c9182d
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 1 deletion.
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,39 @@ jobs:
echo "Success: Found no uncommitted changes"
fi
template_tests:
name: Template tests (optional)
continue-on-error: true
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Commons
uses: ./.github/actions/commons

- name: Install dependencies
run: pnpm i

- name: Build packages
run: pnpm build

- name: Prepare template
run: pnpm --filter @-amazeelabs/silverback-template-tests run prepare-template

- name: Run template tests
run: cd /tmp/silverback-template && pnpm turbo:test

- name: Gatsby log
run: cat /tmp/gatsby.log || true
if: always()
- name: Drupal log
run: cat /tmp/drupal.log || true
if: always()

drupal_updates:
if: startsWith(github.head_ref, 'test-all/') == true
name: Check for forgotten config changes
Expand Down
4 changes: 4 additions & 0 deletions packages/tests/silverback-template/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
extends: ['@amazeelabs/eslint-config'],
root: true,
};
1 change: 1 addition & 0 deletions packages/tests/silverback-template/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@amazeelabs/prettier-config"
21 changes: 21 additions & 0 deletions packages/tests/silverback-template/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@-amazeelabs/silverback-template-tests",
"version": "1.0.0",
"description": "Checks if silverback-template works with the latest changes from the monorepo.",
"author": "Amazee Labs",
"license": "MIT",
"private": true,
"devDependencies": {
"@amazeelabs/eslint-config": "1.4.43",
"@amazeelabs/prettier-config": "1.1.3",
"@types/node": "20.8.5",
"eslint": "8.51.0",
"prettier": "3.0.3",
"tsx": "3.13.0",
"typescript": "5.2.2"
},
"scripts": {
"test:static": "tsc --noEmit && eslint \"**/*.{ts,tsx,js,jsx}\" --ignore-path=\"./.gitignore\" --fix",
"prepare-template": "tsx prepare-template.ts"
}
}
51 changes: 51 additions & 0 deletions packages/tests/silverback-template/prepare-template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { execSync } from 'child_process';

type Package = {
name: string;
version: string;
path: string;
private: boolean;
};

console.log('Clone template and install its deps.');
execSync(
[
'rm -rf /tmp/silverback-template',
'cd /tmp',
'git clone https://github.com/AmazeeLabs/silverback-template.git',
'cd /tmp/silverback-template',
'pnpm i',
].join(' && '),
);

console.log('Make all monorepo public packages available for linking.');
const monoPackages: Array<Package> = JSON.parse(
execSync('pnpm -r exec pnpm list -r --depth -1 --json').toString(),
);
for (const pkg of monoPackages) {
if (!pkg.private && pkg.name.startsWith('@amazeelabs/')) {
execSync(`cd ${pkg.path} && pnpm link --global`);
}
}

console.log('Link monorepo packages to template.');
const templatePackages: Array<Package> = JSON.parse(
execSync(
[
'cd /tmp/silverback-template',
'pnpm -r exec pnpm list -r --depth -1 --json',
].join(' && '),
).toString(),
);
for (const pkg of templatePackages) {
const names = execSync(
`cd ${pkg.path} && ls -1 node_modules/@amazeelabs || true`,
)
.toString()
.split('\n')
.map((it) => it.trim())
.filter((it) => !!it);
for (const name of names) {
execSync(`cd ${pkg.path} && pnpm link --global @amazeelabs/${name}`);
}
}
8 changes: 8 additions & 0 deletions packages/tests/silverback-template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"strict": true,
"skipLibCheck": true,
"lib": ["es2015"],
"types": ["node"]
}
}
38 changes: 37 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3c9182d

Please sign in to comment.