Suites e2e #166
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: Suites e2e | |
env: | |
CI: true | |
on: | |
workflow_dispatch: | |
inputs: | |
target_branch: | |
description: 'E2E Target Branch' | |
required: true | |
permissions: | |
contents: write | |
pull-requests: write | |
id-token: write | |
checks: write | |
statuses: write | |
jobs: | |
status-pending: | |
name: Update PR Status | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
id-token: write | |
checks: write | |
statuses: write | |
steps: | |
- name: Find Pull Request | |
uses: juliangruber/find-pull-request-action@v1 | |
id: pull-request | |
with: | |
branch: ${{ inputs.target_branch }} | |
- name: Update PR e2e Status to Pending | |
run: | | |
curl \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/${{ github.repository }}/statuses/${{ steps.pull-request.outputs.head-sha }} \ | |
-d '{"state":"pending","target_url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}","description":"Running..","context":"Suites e2e"}' | |
e2e: | |
name: Build and Test | |
needs: [status-pending] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
e2e-project: ['jest/nestjs', 'sinon/nestjs', 'vitest/nestjs', 'jest/inversify', 'sinon/inversify', 'vitest/inversify'] | |
node-version: [16.x, 18.x, 20.x] | |
exclude: | |
- e2e-project: 'vitest/inversify' | |
node-version: '16.x' | |
- e2e-project: 'vitest/nestjs' | |
node-version: '16.x' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.target_branch }} | |
- name: Remove Vitest If Needed | |
if: ${{ matrix.node-version == '16.x' }} | |
run: | | |
rm -rf packages/doubles/vitest | |
git config --global user.email "[email protected]" | |
git config --global user.name "Suites CI" | |
git add . | |
git commit -am "remove vitest temp" | |
- name: Setup Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Yarn | |
run: yarn --frozen-lockfile | |
- name: Run Verdaccio Docker | |
run: | | |
docker run -d --name verdaccio \ | |
-p 4873:4873 \ | |
-v ${{ github.workspace }}/e2e/config.yaml:/verdaccio/conf/config.yaml \ | |
verdaccio/verdaccio | |
- name: Build | |
run: yarn build | |
- name: Setup Registry | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: http://localhost:4873 | |
scope: '@suites' | |
always-auth: false | |
- name: Install jq | |
run: sudo apt-get install jq | |
- name: Remove provenance from publishConfig | |
run: | | |
find packages -name 'package.json' | while read filename; do | |
jq 'del(.publishConfig.provenance)' "$filename" > temp.json && mv temp.json "$filename" | |
done | |
- name: Commit Change | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Suites e2e" | |
git add . | |
git commit -am "remove provenance" | |
- name: Publish Packages | |
run: | | |
yarn lerna publish from-package --yes \ | |
--no-git-tag-version \ | |
--no-push \ | |
--no-changelog \ | |
--no-commit-hooks \ | |
--no-git-reset \ | |
--exact \ | |
--force-publish \ | |
--dist-tag e2e | |
- name: Setup and Test | |
run: | | |
IFS='/' read -r library framework <<< "${{ matrix.e2e-project }}" | |
echo "FRAMEWORK=$framework" >> $GITHUB_ENV | |
echo "LIBRARY=$library" >> $GITHUB_ENV | |
- name: Clean Source | |
run: | | |
rm -rf packages | |
rm -rf node_modules | |
- name: Install Dependencies | |
run: | | |
cd "$PWD/e2e/$LIBRARY/$FRAMEWORK" | |
npm install --no-cache --no-package-lock | |
npm install --dev --no-package-lock @types/node@${{ matrix.node-version }} | |
- name: Execute Test | |
run: | | |
cd "$PWD/e2e/$LIBRARY/$FRAMEWORK" | |
npm test | |
update-status: | |
name: Update PR Status | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
id-token: write | |
checks: write | |
statuses: write | |
needs: [status-pending, e2e] | |
if: always() | |
steps: | |
- name: Find Pull Request | |
uses: juliangruber/find-pull-request-action@v1 | |
id: pull-request | |
with: | |
branch: ${{ inputs.target_branch }} | |
- name: Update PR e2e Status (Failed) | |
if: needs.e2e.result == 'failure' | |
run: | | |
curl \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/${{ github.repository }}/statuses/${{ steps.pull-request.outputs.head-sha }} \ | |
-d '{"state":"failure","target_url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}","description":"❌ Failed","context":"Suites e2e"}' | |
- name: Update PR e2e Status (Success) | |
if: needs.e2e.result == 'success' | |
run: | | |
curl \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/${{ github.repository }}/statuses/${{ steps.pull-request.outputs.head-sha }} \ | |
-d '{"state":"success","target_url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}","description":"✅ Passed Successfully","context":"Suites e2e"}' |