Test e2e #1056
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: Test e2e | |
on: | |
pull_request: | |
paths-ignore: | |
- '**/*.md' | |
schedule: | |
- cron: '30 1 * * *' | |
workflow_dispatch: | |
inputs: | |
version_bump: | |
description: 'A type of version bump' | |
default: 'patch' | |
required: true | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
jobs: | |
build-and-deploy-and-test-e2e-mock: | |
runs-on: ubuntu-20.04 | |
name: Build & Deploy & Test e2e using mock app | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.node-version' | |
- name: Install pnpm | |
uses: pnpm/action-setup@129abb77bf5884e578fcaf1f37628e41622cc371 | |
with: | |
version: 8 | |
- name: Upgrade version | |
run: | | |
version_bump=${{ github.event.inputs.version_bump || 'patch' }} | |
pnpm version $version_bump --preid snapshot --no-git-tag | |
- name: Generate random paths | |
run: | | |
postfix=$(date +%s) | |
echo WORKER_NAME=automated-test-$postfix >> $GITHUB_OUTPUT | |
echo WORKER_PATH=fpjs-worker-$postfix >> $GITHUB_OUTPUT | |
echo GET_RESULT_PATH=get-result-$postfix >> $GITHUB_OUTPUT | |
echo AGENT_DOWNLOAD_PATH=agent-download-$postfix >> $GITHUB_OUTPUT | |
id: random-path-generator | |
- name: Modify wrangler.toml | |
run: | | |
sed -i 's/name = .*/name = "${{steps.random-path-generator.outputs.WORKER_NAME}}"/' wrangler.toml | |
sed -i 's/route = .*/route = "${{ secrets.TEST_CLIENT_DOMAIN }}\/${{steps.random-path-generator.outputs.WORKER_PATH}}\/*"/' wrangler.toml | |
echo [vars] >> wrangler.toml | |
echo GET_RESULT_PATH = \"${{ steps.random-path-generator.outputs.GET_RESULT_PATH }}\" >> wrangler.toml | |
echo AGENT_SCRIPT_DOWNLOAD_PATH = \"${{ steps.random-path-generator.outputs.AGENT_DOWNLOAD_PATH }}\" >> wrangler.toml | |
echo PROXY_SECRET = \"secret\" >> wrangler.toml | |
echo FPJS_CDN_URL = \"${{secrets.MOCK_FPCDN}}\" >> wrangler.toml | |
echo FPJS_INGRESS_BASE_HOST = \"${{secrets.MOCK_INGRESS_API}}\" >> wrangler.toml | |
cat wrangler.toml | |
- name: Publish | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.CF_API_TOKEN }} | |
accountId: ${{ secrets.CF_ACCOUNT_ID }} | |
- name: Get version | |
id: version | |
uses: notiz-dev/github-action-json-property@a5a9c668b16513c737c3e1f8956772c99c73f6e8 # commit hash = v0.2.0 | |
with: | |
path: 'package.json' | |
prop_path: 'version' | |
- name: Wait for some time for the worker to come online | |
run: sleep 180 | |
shell: bash | |
- name: Run test | |
run: | | |
npm exec -y "git+https://github.com/fingerprintjs/dx-team-mock-for-proxy-integrations-e2e-tests.git" -- --api-url="${{env.api_url}}" --cdn-proxy-url="https://${{env.test_client_domain}}/${{env.worker_path}}/${{env.agent_download_path}}" --ingress-proxy-url="https://${{env.test_client_domain}}/${{env.worker_path}}/${{env.get_result_path}}" --traffic-name="fingerprintjs-pro-cloudflare" --integration-version="${{steps.version.outputs.prop}}" | |
env: | |
test_client_domain: ${{secrets.TEST_CLIENT_DOMAIN}} | |
worker_version: ${{steps.version.outputs.prop}} | |
worker_path: ${{steps.random-path-generator.outputs.WORKER_PATH}} | |
get_result_path: ${{ steps.random-path-generator.outputs.GET_RESULT_PATH }} | |
agent_download_path: ${{ steps.random-path-generator.outputs.AGENT_DOWNLOAD_PATH }} | |
api_url: https://${{ secrets.MOCK_FPCDN }} | |
- name: Clean up worker | |
run: | | |
curl -i -X DELETE "https://api.cloudflare.com/client/v4/accounts/${{secrets.CF_ACCOUNT_ID}}/workers/scripts/${{steps.random-path-generator.outputs.WORKER_NAME}}" -H"Authorization: bearer ${{secrets.CF_API_TOKEN}}" | |
- name: Report Status | |
if: always() | |
uses: ravsamhq/notify-slack-action@0d9c6ff1de9903da88d24c0564f6e83cb28faca9 | |
with: | |
status: ${{ job.status }} | |
notification_title: "Cloudflare Worker E2E Test using mock app has {status_message}" | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
build-and-deploy-and-test-e2e: | |
runs-on: ubuntu-20.04 | |
name: Build & Deploy & Test e2e | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.node-version' | |
- name: Install pnpm | |
uses: pnpm/action-setup@129abb77bf5884e578fcaf1f37628e41622cc371 | |
with: | |
version: 8 | |
- name: Upgrade version | |
run: | | |
version_bump=${{ github.event.inputs.version_bump || 'patch' }} | |
pnpm version $version_bump --preid snapshot --no-git-tag | |
- name: Generate random paths | |
run: | | |
postfix=$(date +%s) | |
echo WORKER_NAME=automated-test-$postfix >> $GITHUB_OUTPUT | |
echo WORKER_PATH=fpjs-worker-$postfix >> $GITHUB_OUTPUT | |
echo GET_RESULT_PATH=get-result-$postfix >> $GITHUB_OUTPUT | |
echo AGENT_DOWNLOAD_PATH=agent-download-$postfix >> $GITHUB_OUTPUT | |
id: random-path-generator | |
- name: Modify wrangler.toml | |
run: | | |
sed -i 's/name = .*/name = "${{steps.random-path-generator.outputs.WORKER_NAME}}"/' wrangler.toml | |
sed -i 's/route = .*/route = "${{ secrets.TEST_CLIENT_DOMAIN }}\/${{steps.random-path-generator.outputs.WORKER_PATH}}\/*"/' wrangler.toml | |
echo [vars] >> wrangler.toml | |
echo GET_RESULT_PATH = \"${{ steps.random-path-generator.outputs.GET_RESULT_PATH }}\" >> wrangler.toml | |
echo AGENT_SCRIPT_DOWNLOAD_PATH = \"${{ steps.random-path-generator.outputs.AGENT_DOWNLOAD_PATH }}\" >> wrangler.toml | |
echo PROXY_SECRET = \"${{secrets.PROXY_SECRET}}\" >> wrangler.toml | |
cat wrangler.toml | |
- name: Publish | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.CF_API_TOKEN }} | |
accountId: ${{ secrets.CF_ACCOUNT_ID }} | |
- name: Get version | |
id: version | |
uses: notiz-dev/github-action-json-property@a5a9c668b16513c737c3e1f8956772c99c73f6e8 # commit hash = v0.2.0 | |
with: | |
path: 'package.json' | |
prop_path: 'version' | |
- name: Install dependencies | |
run: pnpm exec playwright install | |
- name: Run test | |
run: pnpm test:e2e | |
env: | |
test_client_domain: ${{secrets.TEST_CLIENT_DOMAIN}} | |
worker_version: ${{steps.version.outputs.prop}} | |
worker_path: ${{steps.random-path-generator.outputs.WORKER_PATH}} | |
get_result_path: ${{ steps.random-path-generator.outputs.GET_RESULT_PATH }} | |
agent_download_path: ${{ steps.random-path-generator.outputs.AGENT_DOWNLOAD_PATH }} | |
- name: Clean up worker | |
run: | | |
curl -i -X DELETE "https://api.cloudflare.com/client/v4/accounts/${{secrets.CF_ACCOUNT_ID}}/workers/scripts/${{steps.random-path-generator.outputs.WORKER_NAME}}" -H"Authorization: bearer ${{secrets.CF_API_TOKEN}}" | |
- name: Report Status | |
if: always() | |
uses: ravsamhq/notify-slack-action@0d9c6ff1de9903da88d24c0564f6e83cb28faca9 | |
with: | |
status: ${{ job.status }} | |
notification_title: "Cloudflare Worker E2E Test has {status_message}" | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |