-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(github-actions): extract deploy & e2e job for deployable flag
- Loading branch information
1 parent
3d0a624
commit 75717e5
Showing
5 changed files
with
167 additions
and
59 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
name: 'E2E Tests (backup)' | ||
|
||
on: | ||
workflow_dispatch: | ||
# push: | ||
# branches: [v3.x-bundle] | ||
# paths-ignore: | ||
# - '**/*.md' | ||
# pull_request: | ||
# branches: [ main ] | ||
# paths-ignore: | ||
# - '**/*.md' | ||
|
||
env: | ||
pnpm_version: 8 | ||
node_version: 20 | ||
debug_identifier: nammatham:* | ||
|
||
RESOURCE_IDENTIFIER_NODE18_LINUX_X64: ${{ secrets.RESOURCE_IDENTIFIER_NODE18_LINUX_X64 }} | ||
|
||
jobs: | ||
get-matrix: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 4 | ||
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@v3 | ||
name: Install pnpm | ||
with: | ||
version: ${{ env.pnpm_version }} | ||
|
||
- 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 | ||
timeout-minutes: 10 | ||
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@v3 | ||
name: Install pnpm | ||
with: | ||
version: ${{ env.pnpm_version }} | ||
- 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 | ||
|
||
deploy: | ||
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 }} | ||
path: examples/with-${{ matrix.runtime }}/.nmt/dist | ||
|
||
- name: Deploy to Azure Functions | ||
uses: Azure/functions-action@v1 | ||
with: | ||
app-name: nmt-e2e-${{ matrix.target }}-${{ secrets[matrix.resource_identifier_key] }} | ||
package: . | ||
|
||
e2e: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
- deploy | ||
- get-matrix | ||
timeout-minutes: 10 | ||
strategy: | ||
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@v3 | ||
name: Install pnpm | ||
with: | ||
version: ${{ env.pnpm_version }} | ||
- run: pnpm install | ||
|
||
- name: Run E2E tests | ||
run: pnpm exec nx run @infra/azure-functions:test | ||
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 }} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { test, expect } from 'bun:test'; | ||
import supertest from 'supertest'; | ||
|
||
const url = process.env.AZURE_FUNCTIONS_URL; | ||
const apiKey = process.env.AZURE_FUNCTIONS_API_KEY; | ||
if (!url) throw new Error('AZURE_FUNCTIONS_URL not set'); | ||
if (!apiKey) throw new Error('AZURE_FUNCTIONS_API_KEY not set'); | ||
|
||
test('e2e', async () => { | ||
const response = await fetch(new URL(`/api/SimpleHttpTrigger?code=${apiKey}`, url).toString()); | ||
const response = await supertest(url).get(`/api/SimpleHttpTrigger?code=${apiKey}`); | ||
expect(response.status).toBe(200); | ||
}); |