Skip to content

Commit

Permalink
Merge pull request #16 from hyperweb-io/feat/workflows
Browse files Browse the repository at this point in the history
Add testing workflows
  • Loading branch information
marslavish authored Nov 4, 2024
2 parents cecd39c + c63bfd9 commit 9072645
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Build templates

on:
workflow_dispatch:
pull_request:
types: [opened, reopened, synchronize]

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get examples from directories
id: get-matrix
env:
DIRS: '["templates"]' # Add more dirs here if needed
run: |
# Get examples from each directory
all_examples=$(for dir in $(echo $DIRS | jq -r '.[]'); do
for example in $(ls ./$dir/); do
echo "{\"example\": \"$example\", \"path\": \"$dir\"}"
done
done | jq -s -c '.')
echo "matrix=$all_examples" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}

build:
needs: [setup]
runs-on: ubuntu-latest
strategy:
max-parallel: 4
fail-fast: true
matrix:
include: ${{fromJson(needs.setup.outputs.matrix)}}
env:
EXAMPLE_DIR: ${{ github.workspace }}/dest/${{ matrix.example }}
YARN_ENABLE_IMMUTABLE_INSTALLS: false

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Set up Yarn
uses: threeal/[email protected]

- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
${{ env.EXAMPLE_DIR }}/node_modules
key: ${{ runner.os }}-modules-${{ matrix.example }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-modules-${{ matrix.example }}-
- name: Cache NextJS
uses: actions/cache@v4
with:
path: |
${{ env.EXAMPLE_DIR }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ matrix.example }}-${{ hashFiles(
'${{ env.EXAMPLE_DIR }}/**/*.{js,jsx,ts,tsx}',
'!${{ env.EXAMPLE_DIR }}/node_modules/**',
'!${{ env.EXAMPLE_DIR }}/.next/**',
'!${{ env.EXAMPLE_DIR }}/.yarn/**'
) }}
restore-keys: |
${{ runner.os }}-nextjs-${{ matrix.example }}-
- name: Build example
run: |
echo "Building example: ${{ matrix.example }} from /${{ matrix.path }}"
mkdir -p ${{ env.EXAMPLE_DIR }}
cp -r ./${{ matrix.path }}/${{ matrix.example }}/* ${{ env.EXAMPLE_DIR }}/
cd ${{ env.EXAMPLE_DIR }}
ls -la
yarn install
yarn build
39 changes: 39 additions & 0 deletions .github/workflows/prod-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Run Tests Prod

on:
push:
branches:
- main
workflow_dispatch:

jobs:
run-tests:
runs-on: ubuntu-latest

steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Set up Yarn
uses: threeal/[email protected]
with:
cache: false

- name: Install Dependencies
run: |
echo "YARN_ENABLE_IMMUTABLE_INSTALLS=false" >> $GITHUB_ENV
npm install -g create-hyperweb-app
- name: hyperweb
run: |
cha --template hyperweb --name hyperweb
cd hyperweb
yarn build
- name: chain-admin
run: |
cha --template chain-admin --name chain-admin
cd chain-admin
yarn build

0 comments on commit 9072645

Please sign in to comment.