Skip to content

ci: add e2e test step #36

ci: add e2e test step

ci: add e2e test step #36

Workflow file for this run

name: Build pipeline
on:
push:
branches:
- master
- devel
release:
types: [released]
jobs:
build:
name: πŸ”¨ Build distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: πŸ— Set up Python 3.7
uses: actions/setup-python@v5
with:
python-version: 3.7
- name: πŸ— Install build dependencies
run: >-
python -m pip install wheel --user
- name: πŸ”¨ Build a binary wheel and a source tarball
run: >-
python setup.py sdist bdist_wheel
- 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.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: πŸ— Set up pre-commit
run: |
pip install pre-commit
- name: πŸš€ Run pre-commit
run: |
pre-commit run --all-files --show-diff-on-failure
e2e:
name: πŸ§ͺ E2E tests
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.7", "3.12"]
steps:
- name: "⬇ Checkout OctoPrint with E2E tests"
uses: actions/checkout@v4
with:
repository: OctoPrint/OctoPrint
path: OctoPrint
- 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
run: |
pip install dist/*.whl
cd OctoPrint
pip install .
- name: πŸ— Create base config for test server
run: |
mkdir e2econfig
cp -r OctoPrint/.github/fixtures/with_acl/* e2econfig
- name: πŸ— Install dummy mfa plugin
run: |
mkdir -p e2econfig/plugins
cp -r .github/fixtures/mfa_dummy e2econfig/plugins/mfa_dummy
- name: πŸ— Prepare Playwright env
working-directory: ./OctoPrint/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: ./OctoPrint/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: ./OctoPrint/tests/playwright
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
npx playwright install-deps
- name: 🎭 Run Playwright
working-directory: ./OctoPrint/tests/playwright
run: |
npx playwright test
env:
OCTOPRINT_SERVER_BASE: ${{ github.workspace }}/e2econfig
TEST_MFA: true
- 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-testpypi:
name: πŸ“¦ Publish on TestPyPI
if: github.event_name == 'release'
needs:
- build
- pre-commit
- e2e
runs-on: ubuntu-latest
steps:
- name: ⬇ Download build result
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: πŸ“¦ Publish to index
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
publish-on-pypi:
name: πŸ“¦ Publish tagged releases to PyPI
if: github.event_name == 'release'
needs: publish-on-testpypi
runs-on: ubuntu-latest
steps:
- name: ⬇ Download build result
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: πŸ“¦ Publish to index
uses: pypa/gh-action-pypi-publish@release/v1