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.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@v3 with: name: dist path: dist pre-commit: name: ๐Ÿงน Pre-commit 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: ๐Ÿ— Set up dev dependencies run: | pip install -e .[develop] - name: ๐Ÿš€ Run pre-commit run: | 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"] 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 node-qunit-puppeteer@2.1.0 - 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"] installable: ["wheel", "sdist"] runs-on: ubuntu-latest steps: - name: โฌ‡ Download build result uses: actions/download-artifact@v3 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/OctoPrint-*-py2.py3-none-any.whl - name: ๐Ÿš€ Install source tarball if: matrix.installable == 'sdist' run: | pip install dist/OctoPrint-*.tar.gz test-e2e: name: ๐Ÿงช E2E tests needs: build runs-on: ubuntu-latest steps: - name: โฌ‡ Checkout code uses: actions/checkout@v4 - name: โฌ‡ Download build result uses: actions/download-artifact@v3 with: name: dist path: dist - name: ๐Ÿ— Set up Python 3.7 uses: actions/setup-python@v5 with: python-version: 3.7 - name: ๐Ÿ— Install OctoPrint build run: | pip install dist/OctoPrint-*-py2.py3-none-any.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@v3 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: | npx playwright install --with-deps - name: ๐Ÿ— Install Playwright OS dependencies if: steps.playwright-cache.outputs.cache-hit == 'true' working-directory: ./tests/playwright run: | 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@v3 if: always() with: name: playwright-report path: tests/playwright/playwright-report - name: โฌ† Upload OctoPrint logs uses: actions/upload-artifact@v3 if: failure() with: name: octoprint-logs path: ${{ github.workspace }}/e2econfig/logs publish-on-testpypi: name: ๐Ÿ“ฆ Publish on TestPyPI 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@v3 with: name: dist path: dist - name: ๐Ÿ“ฆ Publish 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@v3 with: name: dist path: dist - 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 }}"}'