|
| 1 | +name: Test e2e for PR |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + |
| 6 | +jobs: |
| 7 | + check-changed-files: |
| 8 | + runs-on: ubuntu-20.04 |
| 9 | + name: Check changed files |
| 10 | + outputs: |
| 11 | + NEED_TO_RUN_TESTS: ${{ steps.decision.outputs.NEED_TO_RUN_TESTS }} |
| 12 | + steps: |
| 13 | + - name: Git clone |
| 14 | + uses: actions/checkout@v4 |
| 15 | + - name: Get changed files |
| 16 | + id: decision |
| 17 | + run: | |
| 18 | + git fetch origin $GITHUB_BASE_REF |
| 19 | + diff=$(git diff --name-only origin/$GITHUB_BASE_REF..HEAD) |
| 20 | + echo $diff |
| 21 | + needToRunTests=false |
| 22 | + for changed_file in $diff; do |
| 23 | + if [[ ${changed_file} =~ ^(src|plugins)\/.+$ ]]; then |
| 24 | + needToRunTests=true |
| 25 | + fi |
| 26 | + if [[ ${changed_file} =~ ^\.github\/workflows\/.+$ ]]; then |
| 27 | + needToRunTests=true |
| 28 | + fi |
| 29 | + done |
| 30 | + echo $needToRunTests |
| 31 | + echo NEED_TO_RUN_TESTS=${needToRunTests} >> $GITHUB_OUTPUT |
| 32 | + build-and-test-e2e-mock: |
| 33 | + runs-on: ubuntu-20.04 |
| 34 | + name: Test e2e for PR using mock app |
| 35 | + needs: check-changed-files |
| 36 | + if: needs['check-changed-files'].outputs.NEED_TO_RUN_TESTS == 'true' |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v4 |
| 39 | + - name: 'Install pnpm' |
| 40 | + uses: pnpm/action-setup@129abb77bf5884e578fcaf1f37628e41622cc371 |
| 41 | + with: |
| 42 | + cache: 'pnpm' |
| 43 | + version: 8 |
| 44 | + - name: Install node |
| 45 | + uses: actions/setup-node@v3 |
| 46 | + with: |
| 47 | + node-version-file: '.node-version' |
| 48 | + - name: Install dependencies |
| 49 | + run: pnpm install |
| 50 | + - name: Extract Branch Name |
| 51 | + id: extract-branch |
| 52 | + run: | |
| 53 | + echo SUBDOMAIN=mock-$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} | perl -pe 's/[^a-zA-Z0-9]+/-/g and s/-+$//g' | tr '[:upper:]' '[:lower:]') >> $GITHUB_OUTPUT |
| 54 | + - name: Set up Fastly CLI |
| 55 | + uses: fastly/compute-actions/setup@v8 |
| 56 | + - name: Package Fastly WASM File |
| 57 | + uses: fastly/compute-actions/build@v8 |
| 58 | + with: |
| 59 | + verbose: true |
| 60 | + env: |
| 61 | + CONFIG_STORE_NAME: "E2ETest" |
| 62 | + - name: Deploy |
| 63 | + id: deploy |
| 64 | + env: |
| 65 | + SERVICE_NAME: "${{steps.extract-branch.outputs.SUBDOMAIN}}.${{secrets.FPJS_CI_DOMAIN}}" |
| 66 | + DEFAULT_ORIGIN: ${{secrets.DEFAULT_ORIGIN}} |
| 67 | + FASTLY_API_TOKEN: ${{secrets.FASTLY_API_TOKEN}} |
| 68 | + FPJS_BACKEND_URL: ${{secrets.MOCK_FPCDN}} |
| 69 | + FPCDN_URL: ${{secrets.MOCK_FPCDN}} |
| 70 | + CONFIG_STORE_NAME: "E2ETest" |
| 71 | + run: pnpm run ci |
| 72 | + - name: Wait for 60s |
| 73 | + shell: bash |
| 74 | + run: sleep 60s |
| 75 | + - name: Run test |
| 76 | + run: pnpm test:mock-e2e |
| 77 | + env: |
| 78 | + TEST_DOMAIN: 'https://fpjs-fastly-${{steps.extract-branch.outputs.SUBDOMAIN}}.edgecompute.app' |
| 79 | + INTEGRATION_PATH: ${{secrets.INTEGRATION_PATH}} |
| 80 | + RESULT_PATH: ${{secrets.RESULT_PATH}} |
| 81 | + AGENT_PATH: ${{secrets.AGENT_PATH}} |
| 82 | + API_URL: ${{secrets.MOCK_FPCDN}} |
0 commit comments