Switch to use NPM_AUTH_TOKEN instead of NODE_AUTH_TOKEN #3666
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: Tests | |
on: [push, pull_request] | |
permissions: | |
contents: read | |
jobs: | |
tests: | |
name: ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- {name: Windows, python: '3.12', os: windows-latest, tox: fail_fast_test_main } | |
# - {name: Mac, python: '3.12', os: macos-latest, tox: fail_fast_test_main } | |
- { name: "ruff", python: "3.11", os: ubuntu-latest, tox: "ruff" } | |
- { name: "mypy", python: "3.10", os: ubuntu-latest, tox: "mypy" } | |
# run some integration tests and abort immediately if they fail, for faster feedback | |
- { name: "Linux", python: "3.12", os: ubuntu-latest, tox: fail_fast_test_main } | |
- { name: "3.12", python: "3.12", os: ubuntu-latest, tox: py312 } | |
- { name: "3.11", python: "3.11", os: ubuntu-latest, tox: py311 } | |
- { name: "3.10", python: "3.10", os: ubuntu-latest, tox: py310 } | |
- { name: "3.9", python: "3.9", os: ubuntu-latest, tox: py39 } | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Set up Python and virtual environment | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Make venv | |
run: | | |
python -m venv .venv | |
- name: Activate the virtualenv | |
if: ${{ matrix.os == 'windows-latest' }} | |
run: | | |
.venv\Scripts\activate | |
- name: Activate the virtualenv | |
if: ${{ matrix.os != 'windows-latest' }} | |
run: | | |
source .venv/bin/activate | |
# Set up poetry and cache for dependencies | |
- name: install poetry | |
run: | | |
python -m pip install poetry | |
poetry config virtualenvs.create false | |
poetry self add "poetry-dynamic-versioning[plugin]" | |
- name: Cache the virtualenv | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: ${{ runner.os }}-venv-${{ hashFiles('pyproject.toml') }} | |
- name: Install versioning plugin | |
run: | | |
python -m pip install poetry-dynamic-versioning[plugin] | |
# Install test dependencies (tox) to the root (non-package install) | |
- name: Install test dependencies | |
run: | | |
poetry install --no-root --only test | |
- name: set full Python version in PY env var | |
if: ${{ matrix.os != 'windows-latest' }} | |
# See https://pre-commit.com/#github-actions-example | |
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV | |
# Install node and yarn in order to build the front end during packaging | |
- name: Set Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install Yarn | |
run: npm install -g yarn | |
- name: Run tox tests | |
run: poetry run tox -e ${{ matrix.tox }} | |
lint_typecheck_test_webui: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- uses: borales/actions-yarn@v5 | |
with: | |
cmd: install | |
dir: locust/webui | |
- uses: borales/actions-yarn@v5 | |
with: | |
cmd: build | |
dir: locust/webui | |
- uses: borales/actions-yarn@v5 | |
with: | |
cmd: test | |
dir: locust/webui | |
- uses: borales/actions-yarn@v5 | |
with: | |
cmd: lint | |
dir: locust/webui | |
- uses: borales/actions-yarn@v5 | |
with: | |
cmd: type-check | |
dir: locust/webui | |
verify_docker_build: | |
name: Always - Docker verify, push to tag 'master' if on master | |
runs-on: ubuntu-latest | |
if: github.event_name != 'pull_request' # PR build doesnt get proper version, so dont try to build it | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# The following steps aren't needed, but if you want 100% guarantee the tagged/release build will work you can add them | |
# - name: Set up Python | |
# uses: actions/setup-python@v5 | |
# with: | |
# python-version: "3.x" | |
# - name: Install dependencies | |
# run: | | |
# python -m pip install --upgrade pip poetry | |
# python -m poetry config virtualenvs.create false | |
# python -m poetry self add "poetry-dynamic-versioning[plugin]" | |
# - run: echo "TAG=$(poetry version -s)" | tee -a $GITHUB_ENV | |
- uses: docker/login-action@v1 | |
if: github.repository_owner == 'locustio' | |
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 publish image | |
id: docker_build | |
uses: docker/build-push-action@v5 | |
with: | |
build-args: | | |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'locustio' }} | |
tags: locustio/locust:master | |
docker_tagged: | |
name: Tagged - Docker push to tag based on git tag. Also push 'latest' if on master | |
needs: tests | |
runs-on: ubuntu-latest | |
if: startsWith(github.event.ref, 'refs/tags') && github.repository_owner == 'locustio' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip poetry | |
python -m poetry config virtualenvs.create false | |
python -m poetry self add "poetry-dynamic-versioning[plugin]" | |
- run: echo "TAG=$(poetry version -s)" | tee -a $GITHUB_ENV | |
- run: echo "BRANCH=$(git branch -a --contains ${{ env.TAG }} | grep -v HEAD | cut -d '/' -f3)" | tee -a $GITHUB_ENV | |
- uses: docker/login-action@v1 | |
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 publish image | |
id: docker_build | |
uses: docker/build-push-action@v5 | |
with: | |
build-args: | | |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: locustio/locust:${{ env.TAG }}${{ ( env.BRANCH == 'master' && ',locustio/locust:latest') || '' }} | |
publish: | |
name: PyPI - Publish if this is a tagged commit | |
needs: [verify_docker_build, tests] | |
if: startsWith(github.event.ref, 'refs/tags') && github.repository_owner == 'locustio' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Set Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install Yarn | |
run: npm install -g yarn | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip poetry | |
python -m poetry config virtualenvs.create false | |
python -m poetry self add "poetry-dynamic-versioning[plugin]" | |
# Pre-build the UI bundle and don't repeat it on the build step to allow sdist to find the files | |
- name: Prebuild UI | |
run: | | |
yarn webui:install | |
yarn webui:build | |
- name: Build + set TAG env var for later use | |
run: | | |
SKIP_PRE_BUILD=true python -m poetry build | |
./rename-wheel.sh | |
echo "TAG=$(poetry version -s)" | tee -a $GITHUB_ENV | |
- name: Publish tagged version to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
skip_existing: true | |
- uses: borales/actions-yarn@v5 | |
name: Publish package on NPM | |
with: | |
cmd: publish --no-git-tag-version --non-interactive --new-version ${{ github.ref_name }} | |
dir: locust/webui | |
env: | |
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
# The following is disabled because it has stopped working. | |
# - name: Tweet on release | |
# uses: infraway/[email protected] | |
# with: | |
# status: "New release: ${{ env.TAG }} https://github.com/locustio/locust/releases/tag/${{ env.TAG }}" | |
# api_key: ${{ secrets.TWITTER_API_CONSUMER_KEY }} | |
# api_key_secret: ${{ secrets.TWITTER_API_CONSUMER_SECRET }} | |
# access_token: ${{ secrets.TWITTER_API_ACCESS_TOKEN_KEY }} | |
# access_token_secret: ${{ secrets.TWITTER_API_ACCESS_TOKEN_SECRET }} | |
publish_prerelease: | |
name: PyPI - Publish prerelease on merge commit on master | |
needs: tests | |
if: github.ref == 'refs/heads/master' && github.repository_owner == 'locustio' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Set Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install Yarn | |
run: npm install -g yarn | |
- run: git rev-parse HEAD^2 2>/dev/null >/dev/null || echo NOT_MERGE_COMMIT=1 | tee -a $GITHUB_ENV | |
- name: Install dependencies | |
if: ${{ env.NOT_MERGE_COMMIT == '' }} | |
run: | | |
python -m pip install --upgrade pip poetry | |
python -m poetry config virtualenvs.create false | |
python -m poetry self add "poetry-dynamic-versioning[plugin]" | |
# Pre-build the UI bundle and don't repeat it on the build step to allow sdist to find the files | |
- name: Prebuild UI | |
run: | | |
yarn webui:install | |
yarn webui:build | |
- name: Build | |
if: ${{ env.NOT_MERGE_COMMIT == '' }} | |
run: | | |
SKIP_PRE_BUILD=true python -m poetry build | |
./rename-wheel.sh | |
- name: Publish prerelease version to PyPI | |
if: ${{ env.NOT_MERGE_COMMIT == '' }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
skip_existing: true | |
- name: Set locust version tag | |
run: echo "TAG=$(poetry version -s | cut -d '.' -f1-3)" | tee -a $GITHUB_ENV | |
- uses: borales/actions-yarn@v5 | |
name: Publish package on NPM | |
with: | |
cmd: publish --no-git-tag-version --non-interactive --tag next --new-version ${{ env.TAG }}-next-${{ github.run_id }} | |
dir: locust/webui | |
env: | |
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |