Hono Middleware for handling function.json (metadata) #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'E2E Tests' | |
on: | |
push: | |
branches: [v3.x] | |
paths-ignore: | |
- '**/*.md' | |
pull_request: | |
branches: [v3.x] | |
paths-ignore: | |
- '**/*.md' | |
env: | |
pnpm_version: 8 | |
node_version: 20 | |
debug_identifier: nammatham:* | |
RESOURCE_IDENTIFIER_NODE18_LINUX_X64: ${{ secrets.RESOURCE_IDENTIFIER_NODE18_LINUX_X64 }} | |
RESOURCE_IDENTIFIER_NODE18_WIN_X64: ${{ secrets.RESOURCE_IDENTIFIER_NODE18_WIN_X64 }} | |
RESOURCE_IDENTIFIER_BUN_LINUX_X64: ${{ secrets.RESOURCE_IDENTIFIER_BUN_LINUX_X64 }} | |
RESOURCE_IDENTIFIER_BUN_WIN_X64: ${{ secrets.RESOURCE_IDENTIFIER_BUN_WIN_X64 }} | |
jobs: | |
get-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.deploy-matrix.outputs.matrix }} | |
deployable_matrix: ${{ steps.deploy-matrix.outputs.deployable_matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
- name: Use Node.js ${{ env.node_version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{env.node_version }} | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
version: ${{ env.pnpm_version }} | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install | |
- name: Export the matrix for testing | |
id: deploy-matrix | |
run: pnpm exec nx run @infra/azure-functions:github-actions | |
build: | |
runs-on: ${{ matrix.os }} | |
needs: get-matrix | |
strategy: | |
matrix: | |
include: ${{fromJson(needs.get-matrix.outputs.matrix)}} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
- name: Use Node.js ${{ matrix.version }} | |
if: matrix.runtime == 'node' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.version }} | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
version: ${{ env.pnpm_version }} | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install | |
- run: pnpm build | |
- name: pnpm install again for ensure the cli is available | |
run: pnpm install | |
- name: Build the project | |
run: pnpm exec nx run @examples/with-${{ matrix.runtime }}:build | |
env: | |
DEBUG: ${{ env.debug_identifier }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.resource_identifier_key }} | |
path: examples/with-${{ matrix.runtime }}/.nmt/dist | |
retention-days: 1 | |
e2e-local: | |
runs-on: ${{ matrix.os }} | |
needs: | |
- build | |
- get-matrix | |
timeout-minutes: 10 | |
env: | |
artifact_download_path: build-functions | |
strategy: | |
matrix: | |
include: ${{fromJson(needs.get-matrix.outputs.matrix)}} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
- name: Use Node.js ${{ matrix.version }} | |
if: matrix.runtime == 'node' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.version }} | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
version: ${{ env.pnpm_version }} | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install | |
# - uses: actions/cache@v4 | |
# name: Cache global npm packages | |
# with: | |
# # a ternary operator | |
# # Ref: https://docs.github.com/en/actions/learn-github-actions/expressions#example | |
# path: ${{ runner.os == 'Windows' && '~/AppData/Roaming/npm-cache' || '~/.npm' }} | |
# key: ${{ runner.os }}-node-global-npm | |
# restore-keys: | | |
# ${{ runner.os }}-node-global-npm | |
- name: Install Azure Functions Core Tools | |
run: npm i -g azure-functions-core-tools@4 --unsafe-perm true | |
# - name: Cache global node_modules | |
# uses: actions/cache@v4 | |
# with: | |
# path: ${{ runner.os == 'Windows' && '~/AppData/Roaming/npm/node_modules' || '/usr/local/lib/node_modules' }} | |
# key: ${{ runner.os }}-node-${{ github.sha }}-global-modules | |
# restore-keys: | | |
# ${{ runner.os }}-node-global-modules | |
- name: Azure Functions Version | |
run: func --version | |
- name: Download Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ matrix.resource_identifier_key }} | |
path: ${{ github.workspace }}/${{ env.artifact_download_path}} | |
- name: Set execute permissions (Linux/macOS) | |
if: runner.os != 'Windows' | |
run: | | |
chmod +x ${{ github.workspace }}/${{ env.artifact_download_path}}/main | |
ls -la ${{ github.workspace }}/${{ env.artifact_download_path}} | |
- name: Set execute permissions (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
icacls.exe "${{ github.workspace }}/${{ env.artifact_download_path}}/main.exe" /grant Everyone:F | |
icacls.exe "${{ github.workspace }}/${{ env.artifact_download_path}}/main.exe" /T /C /Q | |
Get-ChildItem -Path "${{ github.workspace }}/${{ env.artifact_download_path}}" -Force | Format-Table -Property Mode,LastWriteTime,Length,Name | |
- name: Run E2E tests locally | |
run: pnpm exec nx run @infra/e2e-local:test | |
env: | |
CURRENT_WORKING_DIR: ${{ github.workspace }}/${{ env.artifact_download_path}} | |
deploy: | |
# Only run this job on push events | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- get-matrix | |
timeout-minutes: 10 | |
strategy: | |
matrix: | |
include: ${{fromJson(needs.get-matrix.outputs.deployable_matrix)}} | |
steps: | |
- name: Azure Login | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS_E2E_TESTS }} | |
- name: Download Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ matrix.resource_identifier_key }} | |
- name: Deploy to Azure Functions | |
uses: Azure/functions-action@v1 | |
with: | |
app-name: nmt-e2e-${{ matrix.target }}-${{ secrets[matrix.resource_identifier_key] }} | |
package: . | |
e2e-azure: | |
# Only run this job on push events | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- deploy | |
- get-matrix | |
timeout-minutes: 10 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: ${{fromJson(needs.get-matrix.outputs.deployable_matrix)}} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
- name: Use Node.js ${{ env.node_version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.node_version }} | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
version: ${{ env.pnpm_version }} | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run E2E tests | |
run: pnpm exec nx run @infra/azure-functions:test:e2e-remote | |
env: | |
AZURE_FUNCTIONS_URL: https://nmt-e2e-${{ matrix.target }}-${{ secrets[matrix.resource_identifier_key] }}.azurewebsites.net | |
AZURE_FUNCTIONS_API_KEY: ${{ secrets.AZURE_FUNCTIONS_HOST_KEY }} |