-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: wait for codespace to be active before starting test
- Loading branch information
Showing
1 changed file
with
76 additions
and
55 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,81 @@ | ||
--- | ||
name: Acceptance Test | ||
name: Acceptance Test | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
flavor: | ||
required: true | ||
type: string | ||
on: | ||
workflow_call: | ||
inputs: | ||
flavor: | ||
required: true | ||
type: string | ||
|
||
concurrency: | ||
group: ${{ github.workflow }} | ||
cancel-in-progress: false | ||
concurrency: | ||
group: ${{ github.workflow }} | ||
cancel-in-progress: false | ||
|
||
permissions: | ||
contents: read | ||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v9.0.1 | ||
with: | ||
egress-policy: audit | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
persist-credentials: false | ||
# Create a GitHub Codespace and communicate the image version via a Codespace secret (should be a Codespace environment variable). | ||
# This secret is used by devcontainer.json, as such it is a resource that should not be used concurrently. | ||
- run: | | ||
set -Eeuo pipefail | ||
gh secret set -a codespaces IMAGE_VERSION --body "pr-${{ github.event.pull_request.number }}" | ||
echo CODESPACE_NAME="$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ inputs.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h)" >> "$GITHUB_ENV" | ||
env: | ||
GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} | ||
HEAD_REF: ${{ github.head_ref }} | ||
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | ||
with: | ||
node-version: 20 | ||
- run: npm ci | ||
- run: npx playwright install --with-deps | ||
- run: cd test/${{ inputs.flavor }}/features && npm test | ||
env: | ||
GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }} | ||
GITHUB_PASSWORD: ${{ secrets.TEST_GITHUB_PASSWORD }} | ||
GITHUB_TOTP_SECRET: ${{ secrets.TEST_GITHUB_TOTP_SECRET }} | ||
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | ||
if: always() | ||
with: | ||
name: playwright-artifacts | ||
path: | | ||
test-results/ | ||
retention-days: 10 | ||
- run: | | ||
set -Eeuo pipefail | ||
gh codespace delete --force --codespace "$CODESPACE_NAME" | ||
gh secret set -a codespaces IMAGE_VERSION --body "latest" | ||
if: always() | ||
env: | ||
GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v9.0.1 | ||
with: | ||
egress-policy: audit | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
persist-credentials: false | ||
# Create a GitHub Codespace and communicate the image version via a Codespace secret (should be a Codespace environment variable). | ||
# This secret is used by devcontainer.json, as such it is a resource that should not be used concurrently. | ||
- run: | | ||
set -Eeuo pipefail | ||
gh secret set -a codespaces IMAGE_VERSION --body "pr-${{ github.event.pull_request.number }}" | ||
echo CODESPACE_NAME="$(gh codespace create -R "${{ github.repository }}" -b "$HEAD_REF" -m basicLinux32gb --devcontainer-path ".devcontainer/${{ inputs.flavor }}-test/devcontainer.json" --idle-timeout 10m --retention-period 1h)" >> "$GITHUB_ENV" | ||
env: | ||
GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} | ||
HEAD_REF: ${{ github.head_ref }} | ||
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | ||
with: | ||
node-version: 20 | ||
- run: npm ci | ||
- run: npx playwright install --with-deps | ||
- run: | | ||
set -Eeuo pipefail | ||
MAX_WAIT_SECONDS=$((3 * 60)) | ||
SECONDS_ELAPSED=0 | ||
# Wait for the Codespace to be active | ||
while true; do | ||
STATE=$(gh codespace list --json name,state --jq ".[] | select(.name == \"$CODESPACE_NAME\") | .state") | ||
echo "Current state: $STATE" | ||
if [ "$STATE" == "Available" ]; then | ||
echo "Codespace is active!" | ||
break | ||
fi | ||
if [ $SECONDS_ELAPSED -ge $MAX_WAIT_SECONDS ]; then | ||
echo "Timeout reached. Codespace is not active." | ||
exit 1 | ||
fi | ||
sleep 5 | ||
SECONDS_ELAPSED=$((SECONDS_ELAPSED + 5)) | ||
done | ||
- run: cd test/${{ inputs.flavor }}/features && npm test | ||
env: | ||
GITHUB_USER: ${{ secrets.TEST_GITHUB_USER }} | ||
GITHUB_PASSWORD: ${{ secrets.TEST_GITHUB_PASSWORD }} | ||
GITHUB_TOTP_SECRET: ${{ secrets.TEST_GITHUB_TOTP_SECRET }} | ||
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | ||
if: always() | ||
with: | ||
name: playwright-artifacts | ||
path: | | ||
test-results/ | ||
retention-days: 10 | ||
- run: | | ||
set -Eeuo pipefail | ||
gh codespace delete --force --codespace "$CODESPACE_NAME" | ||
gh secret set -a codespaces IMAGE_VERSION --body "latest" | ||
if: always() | ||
env: | ||
GH_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} |