Skip to content

Merge remote-tracking branch 'origin/master' into remove-redundant-st… #795

Merge remote-tracking branch 'origin/master' into remove-redundant-st…

Merge remote-tracking branch 'origin/master' into remove-redundant-st… #795

Workflow file for this run

name: check
on: [push]
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_REPOSITORY: ${{ github.repository }}/e2e
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
working-directory: react
- run: npx eslint .
working-directory: react
build-and-push-image:
runs-on: ubuntu-22.04
outputs:
image: ${{ steps.image.outputs.image }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create the tag by hashing react/test/Dockerfile
id: tag
run: echo "tag=$(shasum -a 256 react/test/Dockerfile requirements.txt | shasum -a 256 | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
- name: concat the Docker image name
id: image
run: echo "image=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}:${{ steps.tag.outputs.tag }}" >> $GITHUB_OUTPUT
- name: Check for existing image
id: existing-image
run: |
GHCR_TOKEN=$(echo -n ${{ secrets.GITHUB_TOKEN }} | base64)
echo "response=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${GHCR_TOKEN}" https://${{ env.DOCKER_REGISTRY }}/v2/${{ env.DOCKER_REPOSITORY }}/manifests/${{ steps.tag.outputs.tag }})" >> $GITHUB_OUTPUT
- name: Log in to the Container registry
if: ${{ steps.existing-image.outputs.response == '404' }}
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
if: ${{ steps.existing-image.outputs.response == '404' }}
uses: docker/build-push-action@v6
with:
context: .
file: react/test/Dockerfile
push: true
tags: ${{ steps.image.outputs.image }}
lint-python:
runs-on: ubuntu-22.04
needs: build-and-push-image
container:
image: ${{ needs.build-and-push-image.outputs.image }}
steps:
- uses: actions/checkout@v4
- name: Lint with pylint
run: python -m pylint --prefer-stubs=true urbanstats
- name: Check black
run: python -m isort urbanstats; python -m black urbanstats; bash -c '[ $(git status --porcelain --untracked-files=no | wc -c) -eq 0 ] || (git status; git diff; exit 1)'
build-frontend:
runs-on: ubuntu-22.04
needs: build-and-push-image
container:
image: ${{ needs.build-and-push-image.outputs.image }}
steps:
- uses: actions/checkout@v4
- run: python3 create_website.py react/test/density-db --no-data --no-geo --no-juxta
- uses: actions/upload-artifact@v4
with:
name: frontend-build
path: react/test/density-db
list-e2e-tests:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: echo "matrix=$(find . -name '*_test.ts' | jq -R -s -c 'gsub("\\./"; "") | gsub("\\.ts"; "") | split("\n")[:-1]')" >> $GITHUB_OUTPUT
working-directory: react/test
run-e2e-tests:
runs-on: ubuntu-22.04
needs: [build-and-push-image, build-frontend, list-e2e-tests]
container:
image: ${{ needs.build-and-push-image.outputs.image }}
strategy:
fail-fast: false
matrix:
test-file: ${{ fromJson(needs.list-e2e-tests.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: frontend-build
path: react/test/density-db
- name: Run tests
run: |
npm ci
npm run test:e2e -- \
--proxy=true \
--browser=chromium \
--test=test/${{ matrix.test-file }}.ts \
--parallel=1 \
--headless=true \
--video=true \
--compare=true
working-directory: react
- uses: actions/upload-artifact@v4
if: "!cancelled()"
with:
name: screenshots-${{ matrix.test-file }}
path: react/screenshots
- uses: actions/upload-artifact@v4
if: "!cancelled()"
with:
name: videos-${{ matrix.test-file }}
path: react/videos
- uses: actions/upload-artifact@v4
if: "!cancelled()"
with:
name: delta-${{ matrix.test-file }}
path: react/delta
- uses: actions/upload-artifact@v4
if: "!cancelled()"
with:
name: changed_screenshots-${{ matrix.test-file }}
path: react/changed_screenshots
merge-screenshots:
runs-on: ubuntu-22.04
needs: [run-e2e-tests]
if: "!cancelled()"
steps:
- uses: actions/upload-artifact/merge@v4
with:
name: screenshots
pattern: "screenshots-*"
- uses: actions/upload-artifact/merge@v4
with:
name: delta
pattern: "delta-*"
continue-on-error: true
- uses: actions/upload-artifact/merge@v4
with:
name: changed_screenshots
pattern: "changed_screenshots-*"
continue-on-error: true
- uses: actions/upload-artifact/merge@v4
with:
name: combined
pattern: "{screenshots,delta,changed_screenshots}"
separate-directories: true