Bump actions/labeler from 4 to 5 #1
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: Build | |
on: | |
push: | |
pull_request: | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: π¨ Build distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: π Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: π Install build dependencies | |
run: | | |
python -m pip install setuptools wheel --user | |
- name: π¨ Build a binary wheel & an sdist tarball | |
run: | | |
python setup.py sdist bdist_wheel | |
- name: π¨ Build a source tarball | |
run: | | |
# find the wheel | |
wheel=$(ls dist/*-py2.py3-none-any.whl) | |
# strip the suffix to get the prefix | |
prefix=$(basename ${wheel%-py2.py3-none-any.whl}) | |
# create the source tarball | |
git archive --prefix $prefix/ HEAD --output dist/$prefix.source.tar.gz | |
# list the files | |
ls dist | |
- name: π¨ Create sha512sums of dist files | |
run: | | |
cd dist | |
sha512sum *.whl *.tar.gz > sha512sums.txt | |
cat sha512sums.txt | |
- name: β¬ Upload build result | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
pre-commit: | |
name: π§Ή Pre-commit | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: π Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: π Run pre-commit | |
run: | | |
pip install pre-commit | |
pre-commit run --all-files --show-diff-on-failure | |
test-unit: | |
name: π§ͺ Unit tests | |
strategy: | |
matrix: | |
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: π Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: π Set up test dependencies | |
run: | | |
pip install -e .[develop] | |
- name: π Run test suite | |
run: | | |
pytest | |
test-js-unit: | |
name: π§ͺ JavaScript unit tests | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: π Set up test dependencies | |
run: | | |
npm -g install [email protected] | |
- name: π Run helpers.js test suite | |
run: | | |
node-qunit-puppeteer tests/static/js/test-helpers.html | |
node-qunit-puppeteer tests/static/js/test-client-base.html | |
test-install: | |
name: π§ͺ Installation tests | |
needs: build | |
strategy: | |
matrix: | |
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] | |
installable: ["wheel", "sdist"] | |
runs-on: ubuntu-latest | |
steps: | |
- name: β¬ Download build result | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: π Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: π Install wheel | |
if: matrix.installable == 'wheel' | |
run: | | |
pip install dist/*.whl | |
- name: π Install source tarball | |
if: matrix.installable == 'sdist' | |
run: | | |
sdist=$(ls dist/*.tar.gz | grep -v source) | |
pip install "$sdist" | |
test-e2e: | |
name: π§ͺ E2E tests | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python: ["3.7", "3.12"] | |
steps: | |
- name: β¬ Checkout code | |
uses: actions/checkout@v4 | |
- name: β¬ Download build result | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: π Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: π Install OctoPrint build | |
run: | | |
pip install dist/*.whl | |
- name: π Create base config for test server | |
run: | | |
mkdir e2econfig | |
cp -r .github/fixtures/with_acl/* e2econfig | |
- name: π Prepare Playwright env | |
working-directory: ./tests/playwright | |
run: | | |
npm ci | |
PLAYWRIGHT_VERSION=$(npm ls --json @playwright/test | jq --raw-output '.dependencies["@playwright/test"].version') | |
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV | |
- name: π§° Cache Playwright browser binaries | |
uses: actions/cache@v4 | |
id: playwright-cache | |
with: | |
path: "~/.cache/ms-playwright" | |
key: "${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}" | |
restore-keys: | | |
${{ runner.os }}-playwright- | |
- name: π Install Playwright browser binaries & OS dependencies | |
if: steps.playwright-cache.outputs.cache-hit != 'true' | |
working-directory: ./tests/playwright | |
run: | | |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list | |
npx playwright install --with-deps | |
- name: π Install Playwright OS dependencies | |
if: steps.playwright-cache.outputs.cache-hit == 'true' | |
working-directory: ./tests/playwright | |
run: | | |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list | |
npx playwright install-deps | |
- name: π Run Playwright | |
working-directory: ./tests/playwright | |
run: | | |
npx playwright test | |
env: | |
OCTOPRINT_SERVER_BASE: ${{ github.workspace }}/e2econfig | |
- name: π Check octoprint.log for errors | |
run: | | |
log=${{ github.workspace }}/e2econfig/logs/octoprint.log | |
if grep "\- ERROR \-" $log; then | |
echo "::error::Errors were logged to octoprint.log" | |
grep -Pazo '(?m)^\N+\- ERROR \-\N*\n(^\N*?\n)*?(?=\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} \- )' $log | |
exit 1 | |
fi | |
- name: β¬ Upload Playwright report | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-report-py${{ matrix.python }} | |
path: tests/playwright/playwright-report | |
- name: β¬ Upload OctoPrint logs | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: octoprint-logs-py${{ matrix.python }} | |
path: ${{ github.workspace }}/e2econfig/logs | |
publish-on-release: | |
name: π¦ Publish build & source on GitHub release | |
if: github.event_name == 'release' && github.repository == 'OctoPrint/OctoPrint' | |
needs: | |
- pre-commit | |
- test-unit | |
- test-js-unit | |
- test-install | |
- test-e2e | |
runs-on: ubuntu-latest | |
steps: | |
- name: β¬ Download build result | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: β¬ Upload to release | |
run: | | |
UPLOAD_URL="https://uploads.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets" | |
for file in dist/*; do | |
[ -e "$file" ] || exit 1 | |
echo "Uploading $file..." | |
response=$(curl -s -XPOST \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: $(file -b --mime-type $file)" \ | |
--data-binary @$file \ | |
"$UPLOAD_URL?name=$(basename $file)") | |
echo "$response" | jq -e '.errors' >/dev/null && echo "Error uploading $file to release: $response" && exit 1 || true | |
done | |
publish-on-testpypi: | |
name: π¦ Publish on TestPyPI | |
if: github.event_name == 'release' && github.repository == 'OctoPrint/OctoPrint' | |
needs: | |
- publish-on-release | |
runs-on: ubuntu-latest | |
steps: | |
- name: β¬ Download build result | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: π§Ή Remove some stuff that won't make it through twine check | |
run: | | |
rm dist/*.source.tar.gz | |
rm dist/sha512sums.txt | |
- name: β¬ Upload to index | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
continue-on-error: true | |
with: | |
password: ${{ secrets.testpypi_password }} | |
repository-url: https://test.pypi.org/legacy/ | |
publish-on-pypi: | |
name: π¦ Publish tagged releases to PyPI | |
if: github.event_name == 'release' && github.repository == 'OctoPrint/OctoPrint' | |
needs: publish-on-testpypi | |
runs-on: ubuntu-latest | |
steps: | |
- name: β¬ Download build result | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: π§Ή Remove some stuff that won't make it through twine check | |
run: | | |
rm dist/*.source.tar.gz | |
rm dist/sha512sums.txt | |
- name: β¬ Publish to index | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.pypi_password }} | |
notify-custopizer-build: | |
name: π§ Notify OctoPi-UpToDate | |
if: github.event_name == 'release' && github.repository == 'OctoPrint/OctoPrint' | |
needs: publish-on-pypi | |
runs-on: ubuntu-latest | |
steps: | |
- name: π Determine version | |
run: | | |
OCTOPRINT_VERSION=$(echo $GITHUB_REF | cut -d/ -f3) | |
echo "OCTOPRINT_VERSION=$OCTOPRINT_VERSION" >> $GITHUB_ENV | |
- name: π Repository Dispatch | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.REPODISPATCH_TOKEN }} | |
repository: OctoPrint/OctoPi-UpToDate | |
event-type: octoprint_release | |
client-payload: '{"version": "${{ env.OCTOPRINT_VERSION }}"}' |