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 adbd2ae
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/actions/commons/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ runs:
${{ steps.node_version.outputs.NODE_VERSION }}
- name: Install pnpm
run: npm install -g pnpm@8
run: npm install -g pnpm@8.6.12
shell: bash
- name: Tell pnpm to use Bash
run: pnpm config set script-shell /bin/bash
Expand Down
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
2 changes: 1 addition & 1 deletion .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM gitpod/workspace-full
RUN npm install -g [email protected].0
RUN npm install -g [email protected].12
RUN sudo update-alternatives --set php $(which php8.1)
RUN sudo install-packages php8.1-gd php8.1-mbstring php8.1-curl php8.1-sqlite3 php8.1-zip php8.1-xdebug
RUN pnpx [email protected] install-deps
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "silverback",
"private": true,
"engines": {
"pnpm": "8"
"pnpm": "8.6.12"
},
"scripts": {
"build": "pnpm -r build",
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"
22 changes: 22 additions & 0 deletions packages/tests/silverback-template/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"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",
"zx": "^7.2.3"
},
"scripts": {
"test:static": "tsc --noEmit && eslint \"**/*.{ts,tsx,js,jsx}\" --ignore-path=\"./.gitignore\" --fix",
"prepare-template": "tsx prepare-template.mts"
}
}
37 changes: 37 additions & 0 deletions packages/tests/silverback-template/prepare-template.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { $ } from 'zx';

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

console.log('Clone template and install its deps.');
await $`rm -rf /tmp/silverback-template`;
await $`cd /tmp && git clone https://github.com/AmazeeLabs/silverback-template.git`;
await $`cd /tmp/silverback-template && pnpm i`;

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

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

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

0 comments on commit adbd2ae

Please sign in to comment.