Skip to content

Commit

Permalink
feat(github-actions): extract deploy & e2e job for deployable flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mildronize committed May 6, 2024
1 parent 3d0a624 commit ce0b6e0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
44 changes: 26 additions & 18 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
path: examples/with-${{ matrix.runtime }}/.nmt/dist
retention-days: 1

e2e:
deploy:
runs-on: ubuntu-latest
needs:
- build
Expand All @@ -94,21 +94,6 @@ jobs:
include: ${{fromJson(needs.get-matrix.outputs.deployable_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@v3
with:
node-version: ${{ matrix.version }}

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: ${{ env.pnpm_version }}
- run: pnpm install

- name: Azure Login
uses: azure/login@v2
with:
Expand All @@ -126,8 +111,31 @@ jobs:
app-name: nmt-e2e-${{ matrix.target }}-${{ secrets[matrix.resource_identifier_key] }}
package: .

- name: Wait for the deployment to finish
run: sleep 15
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@v3
with:
node-version: ${{ env.node_version }}

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: ${{ env.pnpm_version }}
- run: pnpm install

- name: Run E2E tests
run: pnpm exec nx run @infra/azure-functions:test
Expand Down
3 changes: 2 additions & 1 deletion infra/azure-functions/src/e2e.test.ts
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);

Check failure on line 11 in infra/azure-functions/src/e2e.test.ts

View workflow job for this annotation

GitHub Actions / e2e (ubuntu-latest, node, 20, node18-linux-x64, true, RESOURCE_IDENTIFIER_NODE18_LINUX_X64)

error: expect(received).toBe(expected)

Expected: 200 Received: 503 at /home/runner/work/nammatham/nammatham/infra/azure-functions/src/e2e.test.ts:11:3

Check failure on line 11 in infra/azure-functions/src/e2e.test.ts

View workflow job for this annotation

GitHub Actions / e2e (windows-latest, node, 20, node18-win-x64, true, RESOURCE_IDENTIFIER_NODE18_WIN_X64)

error: expect(received).toBe(expected)

Expected: 200 Received: 503 at /home/runner/work/nammatham/nammatham/infra/azure-functions/src/e2e.test.ts:11:3
});

0 comments on commit ce0b6e0

Please sign in to comment.