Merge branch 'master' into playwright_integration #19
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: Run Integration Tests | |
on: | |
push: | |
branches: | |
- playwright_integration | |
concurrency: integration_environment | |
jobs: | |
variables: | |
runs-on: ubuntu-latest | |
outputs: | |
date: ${{ steps.data.outputs.date }} | |
commit: ${{ steps.get-sha.outputs.sha_short }} | |
branch: ${{ steps.branch-name.outputs.current_branch }} | |
runner-image: us-east1-docker.pkg.dev/${{ secrets.DEV_PROJECT}}/containers/hosted-runner:latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Get current date | |
id: date | |
run: echo "date=$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT | |
- name: Set outputs | |
id: get-sha | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Get branch name | |
id: branch-raw | |
uses: tj-actions/[email protected] | |
- name: Format branch name | |
id: branch-name | |
run: >- | |
echo "current_branch="$(echo ${{ steps.branch-raw.outputs.current_branch }} | |
| awk '{print tolower($0)}' | |
| sed 's|.*/\([^/]*\)/.*|\1|; t; s|.*|\0|' | |
| sed 's/[^a-z0-9\.\-]//g') | |
>> $GITHUB_OUTPUT | |
build-generic: | |
needs: | |
- variables | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
app: [ web, node ] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- id: auth | |
name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
token_format: 'access_token' | |
workload_identity_provider: 'projects/${{ secrets.DEV_GKE_PROJECT_ID}}/locations/global/workloadIdentityPools/github/providers/github' | |
service_account: '${{ secrets.DEV_GKE_SA }}' | |
- name: Login to GCR | |
uses: docker/login-action@v1 | |
with: | |
registry: gcr.io | |
username: oauth2accesstoken | |
password: '${{ steps.auth.outputs.access_token }}' | |
- name: Login to GAR | |
uses: docker/login-action@v1 | |
with: | |
registry: us-east1-docker.pkg.dev | |
username: oauth2accesstoken | |
password: '${{ steps.auth.outputs.access_token }}' | |
- name: Generate image metadata | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: | | |
gcr.io/${{ secrets.DEV_PROJECT }}/sefaria-${{ matrix.app }}-${{ needs.variables.outputs.branch }} | |
us-east1-docker.pkg.dev/${{ secrets.DEV_PROJECT }}/containers/sefaria-${{ matrix.app }}-${{ needs.variables.outputs.branch }} | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=ref,event=branch | |
type=sha,enable=true,priority=100,prefix=sha-,suffix=-${{ needs.variables.outputs.date }},format=short | |
type=sha | |
flavor: | | |
latest=true | |
- name: build and push | |
uses: docker/build-push-action@v3 | |
with: | |
# cache-from: type=registry,ref=gcr.io/${{ secrets.DEV_PROJECT }}/sefaria-${{ matrix.app }}/cache | |
# cache-to: type=registry,ref=gcr.io/${{ secrets.DEV_PROJECT }}/sefaria-${{ matrix.app }}/cache, mode=max | |
context: . | |
push: true | |
file: ./build/${{ matrix.app }}/Dockerfile | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-derived: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
needs: | |
- build-generic | |
- variables | |
strategy: | |
matrix: | |
app: [ asset, linker ] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- id: auth | |
name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
token_format: 'access_token' | |
workload_identity_provider: 'projects/${{ secrets.DEV_GKE_PROJECT_ID}}/locations/global/workloadIdentityPools/github/providers/github' | |
service_account: '${{ secrets.DEV_GKE_SA }}' | |
- name: Login to GCR | |
uses: docker/login-action@v1 | |
with: | |
registry: gcr.io | |
username: oauth2accesstoken | |
password: '${{ steps.auth.outputs.access_token }}' | |
- name: Login to GAR | |
uses: docker/login-action@v1 | |
with: | |
registry: us-east1-docker.pkg.dev | |
username: oauth2accesstoken | |
password: '${{ steps.auth.outputs.access_token }}' | |
- name: Generate image metadata | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: | | |
gcr.io/${{ secrets.DEV_PROJECT }}/sefaria-${{ matrix.app }}-${{ needs.variables.outputs.branch }} | |
us-east1-docker.pkg.dev/${{ secrets.DEV_PROJECT }}/containers/sefaria-${{ matrix.app }}-${{ needs.variables.outputs.branch }} | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=ref,event=branch | |
type=sha,enable=true,priority=100,prefix=sha-,suffix=-${{ needs.variables.outputs.date }},format=short | |
type=sha | |
flavor: | | |
latest=true | |
- name: build and push | |
uses: docker/build-push-action@v3 | |
with: | |
# cache-from: type=registry,ref=gcr.io/${{ secrets.DEV_PROJECT }}/sefaria-${{ matrix.app }}/cache | |
# cache-to: type=registry,ref=gcr.io/${{ secrets.DEV_PROJECT }}/sefaria-${{ matrix.app }}/cache,mode=max | |
context: . | |
push: true | |
build-args: | | |
SRC_IMG=us-east1-docker.pkg.dev/${{ secrets.DEV_PROJECT }}/containers/sefaria-web-${{ needs.variables.outputs.branch }}:sha-${{ needs.variables.outputs.commit }} | |
file: ./build/${{ matrix.app }}/Dockerfile | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
run-tests: | |
needs: | |
- build-derived | |
- variables | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
runs-on: sefaria-integrations | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Setup base utils | |
run: | | |
export DEBIAN_FRONTEND=noninteractive | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends curl unzip | |
- name: Setup kubectl | |
uses: azure/setup-kubectl@v3 | |
- name: setup helm | |
uses: azure/setup-helm@v3 | |
- name: Set up yq | |
run: | | |
curl -L https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O | |
sudo mv yq_linux_amd64 /usr/bin/yq | |
chmod +x /usr/bin/yq | |
- name: Deploy Sandbox | |
run: ./build/ci/integration-helm-deploy.sh build/ci/integration-values.yaml | |
env: | |
GIT_COMMIT: "${{ needs.variables.outputs.commit }}" | |
BRANCH: "${{ needs.variables.outputs.branch }}" | |
PROJECT_ID: "${{ secrets.DEV_PROJECT }}" | |
NAMESPACE: "${{secrets.DEV_SANDBOX_NAMESPACE}}" | |
- name: Wait for env | |
run: while [[ $( curl -s -o /dev/null -w "%{http_code}" "nginx-integration-${{ needs.variables.outputs.commit }}.${{secrets.DEV_SANDBOX_NAMESPACE}}/texts") != "200" ]]; do sleep 10; done | |
timeout-minutes: 5 | |
- name: Set SANDBOX_URL | |
run: echo "SANDBOX_URL=http://nginx-integration-${{ needs.variables.outputs.commit }}.${{ secrets.DEV_SANDBOX_NAMESPACE }}/texts" >> $GITHUB_ENV | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Install dependencies | |
run: npm ci | |
- name: Install Playwright Browsers | |
run: npx playwright install --with-deps | |
- name: Run Playwright tests | |
run: npx playwright test | |
- name: Upload Playwright report | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: playwright-report | |
path: playwright-report/ | |
retention-days: 30 | |
- name: Uninstall | |
run: helm delete integration-${{ needs.variables.outputs.commit }} -n ${{ secrets.DEV_SANDBOX_NAMESPACE }} --debug --timeout 10m0s |