Skip to content

Bump actions/labeler from 4 to 5 #1

Bump actions/labeler from 4 to 5

Bump actions/labeler from 4 to 5 #1

Workflow file for this run

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 }}"}'