Skip to content

Commit 9072645

Browse files
authored
Merge pull request #16 from hyperweb-io/feat/workflows
Add testing workflows
2 parents cecd39c + c63bfd9 commit 9072645

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

.github/workflows/build.yaml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Build templates
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, reopened, synchronize]
7+
8+
jobs:
9+
setup:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Get examples from directories
16+
id: get-matrix
17+
env:
18+
DIRS: '["templates"]' # Add more dirs here if needed
19+
run: |
20+
# Get examples from each directory
21+
all_examples=$(for dir in $(echo $DIRS | jq -r '.[]'); do
22+
for example in $(ls ./$dir/); do
23+
echo "{\"example\": \"$example\", \"path\": \"$dir\"}"
24+
done
25+
done | jq -s -c '.')
26+
27+
echo "matrix=$all_examples" >> $GITHUB_OUTPUT
28+
29+
outputs:
30+
matrix: ${{ steps.get-matrix.outputs.matrix }}
31+
32+
build:
33+
needs: [setup]
34+
runs-on: ubuntu-latest
35+
strategy:
36+
max-parallel: 4
37+
fail-fast: true
38+
matrix:
39+
include: ${{fromJson(needs.setup.outputs.matrix)}}
40+
env:
41+
EXAMPLE_DIR: ${{ github.workspace }}/dest/${{ matrix.example }}
42+
YARN_ENABLE_IMMUTABLE_INSTALLS: false
43+
44+
steps:
45+
- name: Checkout repository
46+
uses: actions/checkout@v4
47+
48+
- name: Set up Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: 20
52+
53+
- name: Set up Yarn
54+
uses: threeal/[email protected]
55+
56+
- name: Cache dependencies
57+
uses: actions/cache@v4
58+
with:
59+
path: |
60+
${{ env.EXAMPLE_DIR }}/node_modules
61+
key: ${{ runner.os }}-modules-${{ matrix.example }}-${{ hashFiles('**/yarn.lock') }}
62+
restore-keys: |
63+
${{ runner.os }}-modules-${{ matrix.example }}-
64+
65+
- name: Cache NextJS
66+
uses: actions/cache@v4
67+
with:
68+
path: |
69+
${{ env.EXAMPLE_DIR }}/.next/cache
70+
key: ${{ runner.os }}-nextjs-${{ matrix.example }}-${{ hashFiles(
71+
'${{ env.EXAMPLE_DIR }}/**/*.{js,jsx,ts,tsx}',
72+
'!${{ env.EXAMPLE_DIR }}/node_modules/**',
73+
'!${{ env.EXAMPLE_DIR }}/.next/**',
74+
'!${{ env.EXAMPLE_DIR }}/.yarn/**'
75+
) }}
76+
restore-keys: |
77+
${{ runner.os }}-nextjs-${{ matrix.example }}-
78+
79+
- name: Build example
80+
run: |
81+
echo "Building example: ${{ matrix.example }} from /${{ matrix.path }}"
82+
83+
mkdir -p ${{ env.EXAMPLE_DIR }}
84+
cp -r ./${{ matrix.path }}/${{ matrix.example }}/* ${{ env.EXAMPLE_DIR }}/
85+
cd ${{ env.EXAMPLE_DIR }}
86+
ls -la
87+
88+
yarn install
89+
yarn build

.github/workflows/prod-tests.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Run Tests Prod
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
run-tests:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
19+
- name: Set up Yarn
20+
uses: threeal/[email protected]
21+
with:
22+
cache: false
23+
24+
- name: Install Dependencies
25+
run: |
26+
echo "YARN_ENABLE_IMMUTABLE_INSTALLS=false" >> $GITHUB_ENV
27+
npm install -g create-hyperweb-app
28+
29+
- name: hyperweb
30+
run: |
31+
cha --template hyperweb --name hyperweb
32+
cd hyperweb
33+
yarn build
34+
35+
- name: chain-admin
36+
run: |
37+
cha --template chain-admin --name chain-admin
38+
cd chain-admin
39+
yarn build

0 commit comments

Comments
 (0)