Webui: Fix Failing Tests #4700
Workflow file for this run
This file contains hidden or 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: Tests | |
on: [push, pull_request] | |
permissions: | |
contents: read | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
#------------------------- | |
# Building | |
#------------------------- | |
build_package: | |
name: Build and Cache Packages | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.set_tag.outputs.tag }} | |
tag_short: ${{ steps.set_tag_short.outputs.tag_short }} | |
branch: ${{ steps.set_branch.outputs.branch }} | |
is_merge_commit: ${{ steps.set_is_merge_commit.outputs.is_merge_commit }} | |
is_tag_build: ${{ steps.set_is_tag_build.outputs.is_tag_build }} | |
python_version: ${{ steps.set_python_version.outputs.python_version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- uses: astral-sh/setup-uv@v5 | |
with: | |
version: "0.7.2" | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- run: uv venv | |
- name: Install the project | |
run: uv sync | |
# any local changes would make hatch-vcs set a "local version" (+dev0...), so we ignore any uv.lock updates: | |
- run: git update-index --assume-unchanged uv.lock | |
# Install node and yarn in order to build the front end during packaging | |
- name: Set Node.js 22.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
cache: 'yarn' | |
cache-dependency-path: locust/webui/yarn.lock | |
# Build and upload the project artifacts only once | |
- name: Build Python project and front end | |
run: uv build | |
- name: Upload Python dist as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-dist | |
path: dist/* | |
- name: Upload Web UI as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: webui-dist | |
path: locust/webui/dist/* | |
- name: Build UI library | |
run: yarn webui:build:lib | |
- name: Upload web UI library as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: webui-lib-dist | |
path: locust/webui/lib | |
# Set workflow metadata in one place so we can pull it out later | |
- id: set_tag | |
run: echo "tag=$(uv run hatch version)" | tee -a "$GITHUB_OUTPUT" | |
- id: set_tag_short | |
run: echo "tag_short=$(uv run hatch version | cut -d '.' -f1-3)" | tee -a "$GITHUB_OUTPUT" | |
- id: set_branch | |
run: echo "branch=${{ github.head_ref || github.ref_name }}" | tee -a "$GITHUB_OUTPUT" | |
- id: set_is_merge_commit | |
run: echo "is_merge_commit=$( [ $(git rev-list --count $GITHUB_SHA^@) -eq 2 ] && echo 'true' || echo 'false' )" | tee -a "$GITHUB_OUTPUT" | |
- id: set_is_tag_build | |
run: echo "is_tag_build=${{ startsWith(github.event.ref, 'refs/tags') }}" | tee -a "$GITHUB_OUTPUT" | |
- id: set_python_version | |
run: echo "python_version=$(python -VV | sha256sum | cut -d' ' -f1)" | tee -a "$GITHUB_OUTPUT" | |
print_metadata: | |
name: Display metadata for build | |
runs-on: ubuntu-latest | |
needs: build_package | |
steps: | |
- run: | | |
echo "tag: ${{ needs.build_package.outputs.tag }}" | |
echo "tag_short: ${{ needs.build_package.outputs.tag_short }}" | |
echo "branch: ${{ needs.build_package.outputs.branch }}" | |
echo "is_merge_commit: ${{ needs.build_package.outputs.is_merge_commit }}" | |
echo "is_tag_build: ${{ needs.build_package.outputs.is_tag_build }}" | |
echo "python_version: ${{ needs.build_package.outputs.python_version }}" | |
#------------------------- | |
# Testing | |
#------------------------- | |
tests: | |
name: ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
needs: build_package | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Static analysis and utilities | |
- { name: "Ruff", python: "3.12", os: ubuntu-latest, group: "lint", env: "lint:format" } | |
- { name: "Mypy", python: "3.12", os: ubuntu-latest, group: "lint", env: "lint:types" } | |
# Verification of builds and other aspects | |
- { name: "Docs Build", python: "3.12", os: ubuntu-latest, group: "docs", env: "docs:build" } | |
# OS Integration tests | |
- { name: "Linux", python: "3.12", os: ubuntu-latest, group: "test", env: "integration_test_ci:fail_fast" } | |
- { name: "Windows", python: '3.12', os: windows-latest, group: "test", env: "integration_test_ci:fail_fast" } | |
- { name: "MacOS", python: '3.12', os: macos-latest, group: "test", env: "integration_test_ci:fail_fast" } | |
# Unit tests on Python versions | |
- { name: "Python 3.13", python: "3.13", os: ubuntu-latest, group: "test", env: "test:all" } | |
- { name: "Python 3.12", python: "3.12", os: ubuntu-latest, group: "test", env: "test:all" } | |
- { name: "Python 3.11", python: "3.11", os: ubuntu-latest, group: "test", env: "test:all" } | |
- { name: "Python 3.10", python: "3.10", os: ubuntu-latest, group: "test", env: "test:all" } | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- uses: astral-sh/setup-uv@v5 | |
with: | |
version: "0.7.2" | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- run: uv venv --python ${{ matrix.python }} | |
# Install what we need to run hatch envs but not the project itself | |
- name: Install CI dependencies | |
run: uv sync --group ${{ matrix.group }} --no-install-package locust | |
# Grab the built artifacts to ensure we're testing what we eventually publish | |
- name: Download Python dist | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-dist | |
path: dist | |
- name: Download WebUI dist | |
uses: actions/download-artifact@v4 | |
with: | |
name: webui-dist | |
path: locust/webui/dist | |
- name: Run tests | |
run: uv run --group ${{ matrix.group }} hatch run +py=${{ matrix.python }} ${{ matrix.env }} | |
test_docker_image: | |
name: Test Docker Image | |
runs-on: ubuntu-latest | |
needs: build_package | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Grab the built artifacts to ensure we're testing what we eventually publish | |
- name: Download Python dist | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-dist | |
path: dist | |
# Set up Docker daemon dependencies for building and publishing | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# Build and load Docker image to the local daemon | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile.ci | |
platforms: linux/amd64 | |
load: true | |
tags: locustio/locust:${{ github.sha }}-test | |
# Run a basic test on the image | |
- name: Test docker image | |
run: | | |
docker run --rm locustio/locust:${{ github.sha }}-test --version | |
test_webui: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
cache: 'yarn' | |
cache-dependency-path: locust/webui/yarn.lock | |
- name: yarn install | |
uses: borales/actions-yarn@v5 | |
with: | |
cmd: install | |
dir: locust/webui | |
- name: yarn build | |
uses: borales/actions-yarn@v5 | |
with: | |
cmd: build | |
dir: locust/webui | |
- name: yarn test | |
uses: borales/actions-yarn@v5 | |
with: | |
cmd: test | |
dir: locust/webui | |
- name: yarn lint | |
uses: borales/actions-yarn@v5 | |
with: | |
cmd: lint | |
dir: locust/webui | |
- name: yarn type-check | |
uses: borales/actions-yarn@v5 | |
with: | |
cmd: type-check | |
dir: locust/webui | |
# ------------------------- | |
# Publishing | |
# ------------------------- | |
publish: | |
needs: [tests, test_webui, test_docker_image, build_package] | |
if: github.repository_owner == 'locustio' && ( github.ref == 'refs/heads/master' || startsWith(github.event.ref, 'refs/tags') ) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Download Python dist artifact | |
- name: Download Python dist | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-dist | |
path: dist | |
# Download Web UI lib artifact | |
- name: Download UI lib | |
uses: actions/download-artifact@v4 | |
with: | |
name: webui-lib-dist | |
path: locust/webui/lib | |
# Staged docker builds using exports/artifacts is currently difficult using multi-arch builds with buildx | |
# So let's just build it here | |
# Set docker image and tag values | |
- name: Docker meta | |
id: docker_meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: locustio/locust | |
tags: | | |
type=raw,value=latest,enable=${{ needs.build_package.outputs.is_tag_build }} | |
type=raw,value=${{ needs.build_package.outputs.tag }} | |
type=raw,value=${{ needs.build_package.outputs.branch }} | |
- uses: docker/login-action@v3 | |
with: | |
username: locustbuild | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and (optionally) push docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile.ci | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
skip-existing: true | |
- name: yarn install | |
uses: borales/actions-yarn@v5 | |
with: | |
cmd: install | |
dir: locust/webui | |
# Set pre-release version | |
- name: yarn version | |
uses: borales/actions-yarn@v5 | |
if: github.ref == 'refs/heads/master' | |
with: | |
cmd: version ${{ needs.build_package.outputs.tag_short }}-next-${{ github.run_id }} | |
dir: locust/webui | |
# Set tag build version | |
- name: yarn version | |
uses: borales/actions-yarn@v5 | |
if: startsWith(github.event.ref, 'refs/tags') | |
with: | |
cmd: version ${{ github.ref_name }} | |
dir: locust/webui | |
- name: yarn config | |
uses: borales/actions-yarn@v5 | |
with: | |
cmd: config set npmAuthToken ${{ secrets.NPM_AUTH_TOKEN }} | |
dir: locust/webui | |
# Publish UI lib | |
- uses: borales/actions-yarn@v5 | |
name: Publish package on NPM | |
if: github.ref == 'refs/heads/master' | |
with: | |
cmd: npm publish --tag next | |
dir: locust/webui | |
# On tag builds | |
- uses: borales/actions-yarn@v5 | |
name: Publish package on NPM | |
if: startsWith(github.event.ref, 'refs/tags') | |
with: | |
cmd: npm publish | |
dir: locust/webui |