Skip to content

Commit f19de23

Browse files
committed
Add workflows: build, tests, release
- Add NPM script to create archive - Update dependencies
1 parent 93fa2ee commit f19de23

6 files changed

Lines changed: 163 additions & 12 deletions

File tree

.github/workflows/build.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Shared build workflow before tests/release/publish
2+
name: Build project
3+
permissions:
4+
contents: write
5+
on:
6+
workflow_call: # Can be called from other workflows
7+
# env:
8+
# ACCESS_TOKEN: ${{ secrets.TANGIBLE_PIPELINE_ACCESS_TOKEN }}
9+
jobs:
10+
tests:
11+
timeout-minutes: 15
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
# Composer install - TODO: Only when needed
20+
21+
- name: Set up PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: '8.2'
25+
tools: phpunit-polyfills
26+
# Configure workspace as safe for Git, to solve: https://github.com/composer/composer/issues/12221
27+
- name: Git safe.directory
28+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
29+
- name: Install Composer dependencies
30+
run: composer install --no-interaction --no-progress --optimize-autoloader
31+
32+
# NPM install
33+
- name: Setup Bun
34+
uses: oven-sh/setup-bun@v2
35+
- name: Allow Git access to private repositories
36+
if: ${{ env.ACCESS_TOKEN != '' }}
37+
run: |
38+
echo "https://TangibleInc:$ACCESS_TOKEN@github.com" >> $HOME/.git-credentials
39+
git config --global credential.helper store
40+
- name: Install dependencies
41+
run: bun install
42+
43+
- name: Build assets
44+
run: bun run build

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release
2+
permissions:
3+
contents: write
4+
on:
5+
push:
6+
tags:
7+
- '*'
8+
branches:
9+
- main
10+
jobs:
11+
tests:
12+
uses: ./.github/workflows/tests.yml # Run tests
13+
release:
14+
runs-on: ubuntu-latest
15+
needs: [tests] # Require tests to pass before release
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
- name: Setup Bun
22+
uses: oven-sh/setup-bun@v2
23+
- name: Install dependencies
24+
run: bun install
25+
- name: Create archive
26+
run: bun run archive
27+
- name: Install pipeline
28+
run: mkdir -p publish && cd publish && git clone https://github.com/tangibleinc/pipeline
29+
- name: Add latest tag as needed
30+
uses: EndBug/latest-tag@latest
31+
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
32+
- name: Before release script
33+
run: bun run publish/pipeline/before-release.ts
34+
- name: Release tag
35+
uses: softprops/action-gh-release@v2
36+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
37+
with:
38+
body_path: publish/release.md
39+
files: publish/*.zip
40+
- name: Release preview at latest commit
41+
uses: softprops/action-gh-release@v2
42+
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
43+
with:
44+
body_path: publish/release.md
45+
files: publish/*.zip
46+
tag_name: latest
47+
make_latest: true
48+
- name: After release script
49+
run: bun run publish/pipeline/after-release.ts
50+
# publish:
51+
# uses: ./.github/workflows/publish.yml
52+
# if: ${{ startsWith(github.ref, 'refs/tags/') }}
53+
# needs: [tests] # Require tests to pass before publish

.github/workflows/tests.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Shared tests workflow before release/publish
2+
name: Run tests
3+
permissions:
4+
contents: write
5+
on:
6+
# Release workflow calls this manually for main and tags
7+
push:
8+
branches-ignore:
9+
- 'main'
10+
workflow_call: # Can be called from other workflows
11+
jobs:
12+
build:
13+
uses: ./.github/workflows/build.yml # Build project
14+
tests:
15+
timeout-minutes: 15
16+
runs-on: ubuntu-latest
17+
needs: [build] # Ensure build before tests
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up Docker
25+
uses: docker/setup-docker-action@v4
26+
- name: PHPUnit - Run tests for PHP 7.4
27+
run: bun run test:7.4
28+
- name: PHPUnit - Run tests for PHP 8.2
29+
run: bun run test:8.2
30+
31+
# - name: Jest - Run tests
32+
# run: bun run jest:test
33+
34+
# - name: Install playwright
35+
# run: bun playwright install
36+
# - name: End to end - Run tests
37+
# run: bun run e2e

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/build
3-
3+
/publish
44
/vendor
55
node_modules
66
.idea

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"clean": "rm -rf build",
1717
"dev:libs": "roll dev",
1818
"build:libs": "roll build",
19+
"archive": "roll archive",
1920
"format": "roll format",
2021
"version": "node version.js",
2122
"subrepo": "git-subrepo",
@@ -40,14 +41,14 @@
4041
},
4142
"devDependencies": {
4243
"@gjsify/esbuild-plugin-transform-ext": "^0.0.4",
43-
"@playwright/test": "^1.52.0",
44+
"@playwright/test": "^1.57.0",
4445
"@tangible/git-subrepo": "^1.0.1",
4546
"@tangible/now": "^3.0.2",
46-
"@tangible/roller": "^2.1.4",
47-
"@wordpress/e2e-test-utils-playwright": "^1.22.0",
48-
"esbuild": "^0.25.2",
49-
"globby": "^14.1.0",
47+
"@tangible/roller": "^2.1.9",
48+
"@wordpress/e2e-test-utils-playwright": "^1.36.0",
49+
"esbuild": "^0.27.1",
50+
"globby": "^16.0.0",
5051
"testra": "^2.1.5",
51-
"typescript": "^5.8.3"
52+
"typescript": "^5.9.3"
5253
}
5354
}

tangible.config.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url))
66
export default async () => {
77
const build = []
88

9-
for (const name of [
10-
'api',
11-
'preact',
12-
'select',
13-
]) {
9+
for (const name of ['api', 'preact', 'select']) {
1410
const tasks = (await import(`./${name}/tangible.config.js`)).default.build
1511
build.push(
1612
...tasks.map((task) => ({
@@ -25,5 +21,25 @@ export default async () => {
2521
return {
2622
build,
2723
format: ['**/*.{php,ts,tsx,scss}', '!build'],
24+
archive: {
25+
root: 'tangible-framework',
26+
dest: 'publish/tangible-framework.zip',
27+
src: [
28+
'**/*',
29+
],
30+
exclude: [
31+
'/.*',
32+
'/*.json',
33+
'/*.js',
34+
'/artifacts',
35+
'/publish',
36+
'/tests',
37+
'/vendor',
38+
'*.test.js',
39+
'*.scss',
40+
'*.ts',
41+
'*.tsx',
42+
],
43+
},
2844
}
2945
}

0 commit comments

Comments
 (0)