GHA integration tests #5
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: GHA integration tests | |
on: | |
workflow_dispatch: | |
inputs: | |
lexbox-api-tag: | |
description: 'The version of lexbox-api to test' | |
default: 'develop' | |
required: true | |
workflow_call: | |
inputs: | |
lexbox-api-tag: | |
description: 'The version of lexbox-api to test' | |
default: 'develop' | |
type: string | |
required: true | |
jobs: | |
execute: | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install Task | |
uses: arduino/setup-task@v2 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- run: task setup-local-env | |
- name: setup k8s | |
uses: helm/[email protected] | |
with: | |
config: deployment/gha/kind.yaml | |
- name: Verify k8s | |
run: | | |
kubectl cluster-info | |
kubectl get nodes | |
- name: Update image lexbox-api version | |
uses: mikefarah/yq@0b34c9a00de1c575a34eea05af1d956a525c4fc1 # v4.34.2 | |
with: | |
cmd: yq eval -i '(.images.[] | select(.name == "ghcr.io/sillsdev/lexbox-api").newTag) = "${{ inputs.lexbox-api-tag }}"' "./deployment/gha/kustomization.yaml" | |
# It's also possible that hgweb and/or ui image may have changed; if so, pull them and update kustomization.yaml for them as well | |
- name: Pull hgweb if updated | |
id: hgweb_image | |
continue-on-error: true | |
run: docker pull ghcr.io/sillsdev/lexbox-hgweb:${{ inputs.lexbox-api-tag }} | |
- name: Update image hgweb version | |
if: ${{ steps.hgweb_image.outcome == 'success' }} | |
uses: mikefarah/yq@0b34c9a00de1c575a34eea05af1d956a525c4fc1 # v4.34.2 | |
with: | |
cmd: yq eval -i '(.images.[] | select(.name == "ghcr.io/sillsdev/lexbox-hgweb").newTag) = "${{ inputs.lexbox-api-tag }}"' "./deployment/gha/kustomization.yaml" | |
- name: Pull ui if updated | |
id: ui_image | |
continue-on-error: true | |
run: docker pull ghcr.io/sillsdev/lexbox-ui:${{ inputs.lexbox-api-tag }} | |
- name: Update image ui version | |
if: ${{ steps.ui_image.outcome == 'success' }} | |
uses: mikefarah/yq@0b34c9a00de1c575a34eea05af1d956a525c4fc1 # v4.34.2 | |
with: | |
cmd: yq eval -i '(.images.[] | select(.name == "ghcr.io/sillsdev/lexbox-ui").newTag) = "${{ inputs.lexbox-api-tag }}"' "./deployment/gha/kustomization.yaml" | |
- name: deploy | |
run: | | |
kubectl create namespace languagedepot | |
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.15.0/cert-manager.yaml | |
kubectl wait --for=condition=Ready --timeout=90s pod -l 'app in (cert-manager, webhook)' -n cert-manager | |
kubectl apply -k ./deployment/gha | |
kubectl wait --for=condition=Ready --timeout=120s pod -l 'app.kubernetes.io/component=controller' -n languagedepot | |
kubectl wait --for=condition=Ready --timeout=120s pod -l 'app in (lexbox, ui, hg, db)' -n languagedepot | |
- name: forward ingress | |
run: | | |
kubectl port-forward service/ingress-nginx-controller 6579:80 -n languagedepot & | |
kubectl port-forward service/lexbox 1080:1080 -n languagedepot & | |
- name: verify ingress | |
run: curl -v http://localhost:6579 | |
- name: build | |
run: dotnet restore LexBoxOnly.slnf && dotnet build --no-restore LexBoxOnly.slnf | |
- name: Dotnet test | |
env: | |
TEST_SERVER_HOSTNAME: 'localhost:6579' | |
TEST_STANDARD_HG_HOSTNAME: 'hg.localhost:6579' | |
TEST_RESUMABLE_HG_HOSTNAME: 'resumable.localhost:6579' | |
TEST_PROJECT_CODE: 'sena-3' | |
TEST_DEFAULT_PASSWORD: 'pass' | |
run: dotnet test LexBoxOnly.slnf --logger GitHubActions --filter "Category=Integration|Category=FlakyIntegration" --blame-hang-timeout 40m | |
##playwright tests | |
# First we need to setup Node... | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: 'frontend/package.json' | |
# Then we can set up pnpm... | |
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0 | |
with: | |
package_json_file: 'frontend/package.json' | |
# Then we can have Node set up package caching | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: 'frontend/package.json' | |
cache: 'pnpm' | |
cache-dependency-path: 'frontend/pnpm-lock.yaml' | |
- name: Playwright setup | |
working-directory: frontend | |
run: pnpm install | |
- name: Set up Playwright dependencies | |
working-directory: frontend | |
run: pnpm exec playwright install --with-deps | |
- name: Integration tests (Playwright) | |
id: playwright-tests | |
env: | |
TEST_SERVER_HOSTNAME: 'localhost:6579' | |
TEST_STANDARD_HG_HOSTNAME: 'hg.localhost:6579' | |
TEST_RESUMABLE_HG_HOSTNAME: 'resumable.localhost:6579' | |
TEST_PROJECT_CODE: 'sena-3' | |
TEST_DEFAULT_PASSWORD: 'pass' | |
working-directory: frontend | |
run: pnpm test | |
- name: Upload playwright results | |
if: ${{ always() && steps.playwright-tests.outcome != 'skipped' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: playwright-traces-${{ inputs.runs-on }}-hg-${{ inputs.hg-version }} | |
path: | | |
./frontend/test-results | |
- name: status | |
if: failure() | |
run: | | |
mkdir -p k8s-logs | |
for app in lexbox ui hg db; do | |
kubectl describe pods -l "app=${app}" -n languagedepot > k8s-logs/describe-${app}.txt | |
kubectl logs -l "app=${app}" -n languagedepot --prefix --all-containers --tail=-1 > k8s-logs/logs-${app}.txt | |
done | |
kubectl logs -l 'app.kubernetes.io/name=ingress-nginx' -n languagedepot --prefix --all-containers --tail=-1 > k8s-logs/logs-ingress.txt | |
- name: upload status | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: k8s-logs | |
path: k8s-logs/*.txt | |