Files
RASCSI/.github/workflows/web.yml

149 lines
4.4 KiB
YAML

name: Web Tests/Analysis
on:
push:
branches:
- develop
- main
paths:
- '.github/workflows/web.yml'
- 'easyinstall.sh'
- 'python/**'
pull_request:
branches:
- develop
- main
types:
- opened
- synchronize
- reopened
paths:
- '.github/workflows/web.yml'
- 'easyinstall.sh'
- 'python/**'
jobs:
backend_checks:
runs-on: ubuntu-latest
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: 3.9.25
cache: 'pip'
- run: pip install -r web/requirements-dev.txt
id: pip
- run: black --check .
- run: flake8 .
if: success() || failure() && steps.pip.outcome == 'success'
backend_tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: docker
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set backend container image name
run: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
IMAGE_TAG=$(git ls-files -s cpp proto .github/workflows/web.yml | git hash-object --stdin)
echo "GHCR_IMAGE=ghcr.io/${REPO_LOWER}/backend-standalone:${IMAGE_TAG}" >> $GITHUB_ENV
- name: Login to container registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and launch containers
run: docker compose -f docker-compose.ci.yml up -d
- name: Run test suite
run: docker compose -f docker-compose.ci.yml run pytest -v
- name: Push backend image to container registry
if: |
(success() || failure())
&& github.actor != 'dependabot[bot]'
&& github.actor != 'dependabot'
&& (
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository
)
run: docker compose -f docker-compose.ci.yml push backend
- name: Upload test artifacts
if: success() || failure()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: pytest-output.zip
path: |
docker/volumes/pytest/report.xml
docker/volumes/pytest/pytest.log
- name: Output container logs
if: success() || failure()
run: |
docker compose -f docker-compose.ci.yml logs backend > backend.log
docker compose -f docker-compose.ci.yml logs web > web.log
docker compose -f docker-compose.ci.yml logs -t | sort -u -k 3 > combined.log
- name: Upload backend log
if: success() || failure()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: backend.log
path: docker/backend.log
- name: Upload web log
if: success() || failure()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: web.log
path: docker/web.log
- name: Upload combined log
if: success() || failure()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: combined.log
path: docker/combined.log
frontend_checks:
runs-on: ubuntu-latest
defaults:
run:
working-directory: python/web
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version: 24
cache: 'npm'
cache-dependency-path: python/web/package-lock.json
- run: npm ci
id: npm
- name: Stylelint
run: |
npx stylelint src/static/themes/modern/style.css
npx stylelint src/static/themes/classic/style.css
- name: Prettier
run: |
npx prettier --check src/static/themes/modern/style.css
npx prettier --check src/static/themes/classic/style.css
if: success() || failure() && steps.npm.outcome == 'success'