Workspace integration tests #1368
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: "Workspace integration tests" | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
on: | |
workflow_dispatch: | |
inputs: | |
name: | |
required: false | |
type: string | |
description: "The name of the preview environment, or leave empty to use a default name" | |
version: | |
required: false | |
type: string | |
description: "The version of Gitpod to install (leave empty to target the latest successful build on main)" | |
image_repo_base: | |
type: choice | |
required: false | |
description: "The base repo of image" | |
options: | |
- "eu.gcr.io/gitpod-core-dev/build" | |
- "eu.gcr.io/gitpod-dev-artifact/build" | |
default: "eu.gcr.io/gitpod-core-dev/build" | |
skip_deploy: | |
required: false | |
type: boolean | |
description: "Skip deploy preview environment (debug only)" | |
skip_delete: | |
required: false | |
type: boolean | |
description: "Skip delete preview environment (debug only)" | |
workflow_call: | |
inputs: | |
name: | |
required: false | |
type: string | |
description: "The name of the preview environment, or leave empty to use a default name" | |
version: | |
required: false | |
type: string | |
description: "The version of Gitpod to install (leave empty to target the latest successful build on main)" | |
image_repo_base: | |
type: string | |
required: false | |
description: "The base repo of image" | |
default: "eu.gcr.io/gitpod-core-dev/build" | |
schedule: | |
- cron: "0 3,12 * * *" | |
jobs: | |
create-runner: | |
uses: gitpod-io/gce-github-runner/.github/workflows/create-vm.yml@main | |
secrets: | |
runner_token: ${{ secrets.SELF_HOSTED_GITHUB_RUNNER_TOKEN }} | |
gcp_credentials: ${{ secrets.SELF_HOSTED_GITHUB_RUNNER_GCP_CREDENTIALS }} | |
with: | |
task: workspace-integration-tests | |
configuration: | |
name: Configuration | |
runs-on: ${{ needs.create-runner.outputs.label }} | |
needs: [create-runner] | |
container: | |
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:pd-test-new-preview-gha.24525 | |
outputs: | |
name: ${{ steps.configuration.outputs.name }} | |
version: ${{ steps.configuration.outputs.version }} | |
image_repo_base: ${{ steps.configuration.outputs.image_repo_base }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: "Set outputs" | |
id: configuration | |
shell: bash | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if [[ '${{ inputs.name }}' != '' ]]; then | |
{ | |
echo "name=${{ inputs.name }}" | |
} >> $GITHUB_OUTPUT | |
else | |
{ | |
echo "name=workspace-integration-test-${{ github.run_id }}-${{ github.run_attempt }}" | |
} >> $GITHUB_OUTPUT | |
fi | |
if [[ '${{ inputs.version }}' != '' ]]; then | |
{ | |
echo "version=${{ inputs.version }}" | |
} >> $GITHUB_OUTPUT | |
else | |
# Search the last 10 builds regardless of status (success and failed) | |
RUNID=$(gh run list --repo gitpod-io/gitpod --branch main --workflow build.yml --limit 10 --json createdAt,conclusion,databaseId --jq 'map(select(.conclusion == "success")) | sort_by(.createdAt) | .[-1] | .databaseId') | |
if [ "$RUNID" == "" ]; then | |
echo no successful build found on main branch in the last 10 commits, see https://github.com/gitpod-io/gitpod/actions/workflows/build.yml for details | tee -a $GITHUB_STEP_SUMMARY | |
# if we got here, it means in the last 10 builds on main, there wasn't a success, and then we'll keep getting this message | |
# to fix, manually trigger the tests with the latest main-gha asset till we get a success | |
# you might have to fix or disable flakey tests to do this | |
# | |
# for posterity, this will show when the last success actually was, but it shouldn't be used to get RUNID | |
# gh run list --repo gitpod-io/gitpod --branch main --workflow build.yml --limit 10 --json createdAt,conclusion,databaseId --status success --jq 'sort_by(.createdAt) | .[-1]' | |
exit 1 | |
fi | |
{ | |
echo "version=$(gh run view "$RUNID" --log -R gitpod-io/gitpod | grep 'main-gha.[0-9]*' -o | head -n 1)" | |
} >> $GITHUB_OUTPUT | |
fi | |
if [[ '${{ inputs.image_repo_base }}' != '' ]]; then | |
{ | |
echo "image_repo_base=${{ inputs.image_repo_base }}" | |
} >> $GITHUB_OUTPUT | |
else | |
{ | |
echo "image_repo_base=eu.gcr.io/gitpod-core-dev/build" | |
} >> $GITHUB_OUTPUT | |
fi | |
- name: Slack Notification | |
uses: rtCamp/action-slack-notify@v2 | |
if: failure() | |
env: | |
SLACK_WEBHOOK: ${{ secrets.WORKSPACE_SLACK_WEBHOOK }} | |
SLACK_ICON_EMOJI: ":test_tube:" | |
SLACK_USERNAME: "Integration Tests: workspace" | |
SLACK_COLOR: ${{ job.status }} | |
SLACK_MESSAGE: "Workspace Integration Tests failed during configuration, is main build green?" | |
SLACK_FOOTER: "<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Workflow logs>" | |
infrastructure: | |
needs: [configuration, create-runner] | |
runs-on: ${{ needs.create-runner.outputs.label }} | |
concurrency: | |
group: ${{ needs.configuration.outputs.name }}-infrastructure | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Environment | |
uses: ./.github/actions/setup-environment | |
with: | |
identity_provider: ${{ secrets.DEV_PREVIEW_PROVIDER }} | |
service_account: ${{ secrets.DEV_PREVIEW_SA }} | |
leeway_segment_key: ${{ secrets.LEEWAY_SEGMENT_KEY }} | |
- name: Create preview environment infrastructure | |
id: create | |
uses: ./.github/actions/preview-create | |
with: | |
name: ${{ needs.configuration.outputs.name }} | |
infrastructure_provider: gce | |
large_vm: true | |
preemptible: true | |
image_repo_base: ${{ needs.configuration.outputs.image_repo_base }} | |
- name: Deploy Gitpod to the preview environment | |
if: inputs.skip_deploy != 'true' | |
id: deploy-gitpod | |
uses: ./.github/actions/deploy-gitpod | |
with: | |
name: ${{ needs.configuration.outputs.name }} | |
version: ${{ needs.configuration.outputs.version }} | |
image_repo_base: ${{ needs.configuration.outputs.image_repo_base }} | |
check: | |
name: Check for regressions | |
needs: [configuration, infrastructure, create-runner] | |
runs-on: ${{ needs.create-runner.outputs.label }} | |
container: | |
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:pd-test-new-preview-gha.24525 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Integration Test | |
id: integration-test | |
uses: ./.github/actions/integration-tests | |
with: | |
preview_name: ${{ needs.configuration.outputs.name }} | |
test_suite: workspace | |
notify_slack_webhook: ${{ secrets.WORKSPACE_SLACK_WEBHOOK }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
identity_provider: ${{ secrets.DEV_PREVIEW_PROVIDER }} | |
service_account: ${{ secrets.DEV_PREVIEW_SA }} | |
leeway_segment_key: ${{ secrets.LEEWAY_SEGMENT_KEY }} | |
integration_test_username: ${{ secrets.WORKSPACE_INTEGRATION_TEST_USERNAME }} | |
integration_test_usertoken: ${{ secrets.WORKSPACE_INTEGRATION_TEST_USER_TOKEN }} | |
delete: | |
name: Delete preview environment | |
needs: [configuration, infrastructure, check, create-runner] | |
if: inputs.skip_delete != 'true' && always() | |
runs-on: ${{ needs.create-runner.outputs.label }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Environment | |
uses: ./.github/actions/setup-environment | |
with: | |
identity_provider: ${{ secrets.DEV_PREVIEW_PROVIDER }} | |
service_account: ${{ secrets.DEV_PREVIEW_SA }} | |
leeway_segment_key: ${{ secrets.LEEWAY_SEGMENT_KEY }} | |
- name: Delete preview environment | |
uses: ./.github/actions/delete-preview | |
with: | |
name: ${{ needs.configuration.outputs.name }} | |
delete-runner: | |
if: always() | |
needs: | |
- create-runner | |
- configuration | |
- infrastructure | |
- check | |
- delete | |
uses: gitpod-io/gce-github-runner/.github/workflows/delete-vm.yml@main | |
secrets: | |
gcp_credentials: ${{ secrets.SELF_HOSTED_GITHUB_RUNNER_GCP_CREDENTIALS }} | |
with: | |
runner-label: ${{ needs.create-runner.outputs.label }} | |
machine-zone: ${{ needs.create-runner.outputs.machine-zone }} |