Skip to content

Migrate fastly integration tests to new service #250

Migrate fastly integration tests to new service

Migrate fastly integration tests to new service #250

name: Integration Test Akamai
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}-integrate-akamai
cancel-in-progress: true
jobs:
build:
uses: ./.github/workflows/build_akamai.yml
deploy:
runs-on: ubuntu-latest
needs: [build]
defaults:
run:
working-directory: ./bindings/akamai
steps:
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: "npm"
- run: npm ci
- uses: actions/download-artifact@v4
with:
name: akamai-dist
path: bindings/akamai/dist
- run: wget https://github.com/akamai/cli/releases/download/v1.6.0/akamai-v1.6.0-linuxamd64
- run: chmod +x akamai-v1.6.0-linuxamd64
- run: mv akamai-v1.6.0-linuxamd64 /usr/local/bin/akamai
- run: printf "${{ secrets.AKAMAI_EDGERC }}" >> ~/.edgerc
- run: akamai install edgeworkers # edgeworkers subcommand must be explicitly installed
- run: echo ::add-mask::${{ secrets.AKAMAI_EMAIL }}
- name: Get Next Version
id: get-next-version
run: |
latest_version=$(akamai ew list-versions --edgerc ~/.edgerc --jsonout ${{ secrets.AKAMAI_INTEGRATION_EW_ID }} | jq -r .data[-1].version)
echo latest version: $latest_version
next_version=$(awk -F. '{printf "%s.%s.%s", $1, $2, $3+1}' <<< "$latest_version")
echo next version: $next_version
echo "LATEST_VERSION=$latest_version" >> "$GITHUB_OUTPUT"
echo "NEXT_VERSION=$next_version" >> "$GITHUB_OUTPUT"
- name: Produce Bundle
run: |
echo "{\"edgeworker-version\": \"${{ steps.get-next-version.outputs.NEXT_VERSION }}\"}" > dist/bundle.json
npm run pack
echo package created.
akamai ew validate pkg/akamai_client.tar.gz
- name: Upload Bundle
run: akamai ew upload --edgerc ~/.edgerc --jsonout --bundle pkg/akamai_client.tar.gz ${{ secrets.AKAMAI_INTEGRATION_EW_ID }}
- name: Activate Bundle
run: akamai ew activate --edgerc ~/.edgerc --jsonout ${{ secrets.AKAMAI_INTEGRATION_EW_ID }} production ${{ steps.get-next-version.outputs.NEXT_VERSION }}
- name: Wait for Activation
run: |
timeout=600
start_time=$(date +%s)
while true; do
out=$(akamai ew status --edgerc ~/.edgerc --jsonout ${{ secrets.AKAMAI_INTEGRATION_EW_ID }} --versionId ${{ steps.get-next-version.outputs.NEXT_VERSION }})
if [[ $(echo $out | jq -r .data[0].status) == "COMPLETE" ]]; then
echo "Akamai activation completed successfully."
break
fi
if (( $(date +%s) - $start_time >= $timeout )); then
echo "Akamai activation timeout out after $timeout seconds. Status: $(echo $out | jq .data[0].status), expected COMPLETE."
break
fi
echo "Deployment status: $(echo $out | jq .data[0].status). Sleeping"
sleep 10
done
- name: Set Properties
run: echo TODO
test:
needs: [deploy]
timeout-minutes: 60
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./integration/playwright_tests
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
env:
ENDPOINT: ${{ secrets.AKAMAI_ENDPOINT }}
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: ./integration/playwright_report/
retention-days: 30