diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..b8a6ba11 --- /dev/null +++ b/.github/workflows/build.yaml @@ -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/setup-yarn-action@v2.0.0 + + - 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 diff --git a/.github/workflows/prod-tests.yaml b/.github/workflows/prod-tests.yaml new file mode 100644 index 00000000..4eef3c6a --- /dev/null +++ b/.github/workflows/prod-tests.yaml @@ -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/setup-yarn-action@v2.0.0 + 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