| # Configuration for Python CI |
| # To force the execution of this workflow, add [run python] to your commit message |
| name: 'CI - Python' |
| |
| on: |
| workflow_dispatch: |
| |
| schedule: |
| - cron: '05 9,21 * * *' |
| |
| push: |
| |
| pull_request: |
| |
| jobs: |
| check_workflow: |
| permissions: |
| contents: none |
| uses: ./.github/workflows/should-workflow-run.yml |
| with: |
| bazel-target-prefix: '//py' |
| |
| tox_linting: |
| if: ${{ needs.check_workflow.outputs.result == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(toJson(github.event.commits), '[py]') == true }} |
| needs: check_workflow |
| runs-on: ubuntu-20.04 |
| steps: |
| - name: Checkout source tree |
| uses: actions/checkout@v3 |
| - name: Set up Python 3.7 |
| uses: actions/setup-python@v4 |
| with: |
| python-version: 3.7.10 |
| - name: Install dependencies |
| run: | |
| python -m pip install --upgrade pip |
| pip install tox==2.4.1 |
| - name: Test with tox |
| run: tox -c py/tox.ini |
| env: |
| TOXENV: linting-check |
| |
| tox_docs: |
| if: ${{ needs.check_workflow.outputs.result == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(toJson(github.event.commits), '[run python]') == true }} |
| needs: check_workflow |
| runs-on: ubuntu-20.04 |
| steps: |
| - name: Checkout source tree |
| uses: actions/checkout@v3 |
| - name: Set up Python 3.7 |
| uses: actions/setup-python@v4 |
| with: |
| python-version: 3.7.10 |
| - name: Install dependencies |
| run: | |
| python -m pip install --upgrade pip |
| pip install tox==2.4.1 |
| - name: Test with tox |
| run: tox -c py/tox.ini |
| env: |
| TOXENV: docs |
| |
| tox_mypy: |
| if: ${{ needs.check_workflow.outputs.result == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(toJson(github.event.commits), '[run python]') == true }} |
| needs: check_workflow |
| runs-on: ubuntu-20.04 |
| steps: |
| - name: Checkout source tree |
| uses: actions/checkout@v3 |
| - name: Set up Python 3.7 |
| uses: actions/setup-python@v4 |
| with: |
| python-version: 3.7.9 |
| - name: Install dependencies |
| run: | |
| python -m pip install --upgrade pip |
| pip install tox==2.4.1 |
| - name: Test with tox |
| run: | |
| tox -c py/tox.ini -- --cobertura-xml-report ci || true |
| bash <(curl -s https://codecov.io/bash) -f py/ci/cobertura.xml |
| env: |
| TOXENV: mypy |
| |
| unit_tests: |
| if: ${{ needs.check_workflow.outputs.result == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(toJson(github.event.commits), '[run python]') == true }} |
| needs: check_workflow |
| runs-on: ubuntu-latest |
| steps: |
| - name: Checkout source tree |
| uses: actions/checkout@v3 |
| - name: Cache Bazel artifacts |
| uses: actions/cache@v3 |
| with: |
| path: | |
| ~/.cache/bazel-disk |
| ~/.cache/bazel-repo |
| key: ${{ runner.os }}-bazel-python-unit-tests-${{ hashFiles('**/BUILD.bazel') }} |
| restore-keys: | |
| ${{ runner.os }}-bazel-python-unit-tests- |
| - name: Setup Java |
| uses: actions/setup-java@v3 |
| with: |
| java-version: '11' |
| distribution: 'temurin' |
| - name: Run unit tests |
| uses: ./.github/actions/bazel |
| with: |
| command: test //py:unit |
| |
| chrome_tests: |
| if: ${{ needs.check_workflow.outputs.result == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(toJson(github.event.commits), '[run python]') == true }} |
| needs: [ check_workflow, unit_tests ] |
| runs-on: ubuntu-latest |
| steps: |
| - name: Checkout source tree |
| uses: actions/checkout@v3 |
| - name: Cache Bazel artifacts |
| uses: actions/cache@v3 |
| with: |
| path: | |
| ~/.cache/bazel-disk |
| ~/.cache/bazel-repo |
| key: ${{ runner.os }}-bazel-chrome-tests-${{ hashFiles('**/BUILD.bazel') }} |
| restore-keys: | |
| ${{ runner.os }}-bazel-chrome-tests- |
| ${{ runner.os }}-bazel-python-unit-tests- |
| - name: Setup Fluxbox |
| run: sudo apt-get -y install fluxbox |
| - name: Setup Chrome |
| uses: browser-actions/setup-chrome@latest |
| - name: Start XVFB |
| run: Xvfb :99 & |
| - name: Start Fluxbox |
| run: fluxbox -display :99 & |
| - name: Run browser tests in Chrome |
| uses: ./.github/actions/bazel-test |
| with: |
| query: //py:test-chrome |
| attempts: 3 |
| env: |
| DISPLAY: :99 |
| |
| firefox_tests_remote: |
| if: ${{ needs.check_workflow.outputs.result == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(toJson(github.event.commits), '[run python]') == true }} |
| needs: [ check_workflow, unit_tests ] |
| runs-on: ubuntu-latest |
| steps: |
| - name: Checkout source tree |
| uses: actions/checkout@v3 |
| - name: Cache Bazel artifacts |
| uses: actions/cache@v3 |
| with: |
| path: | |
| ~/.cache/bazel-disk |
| ~/.cache/bazel-repo |
| key: ${{ runner.os }}-bazel-firefox-tests-${{ hashFiles('**/BUILD.bazel') }} |
| restore-keys: | |
| ${{ runner.os }}-bazel-firefox-tests- |
| ${{ runner.os }}-bazel-python-unit-tests- |
| - name: Setup Fluxbox |
| run: sudo apt-get -y install fluxbox |
| - name: Setup Java |
| uses: actions/setup-java@v3 |
| with: |
| java-version: '11' |
| distribution: 'temurin' |
| - name: Setup Firefox |
| uses: abhi1693/setup-browser@v0.3.4 |
| with: |
| browser: firefox |
| version: latest |
| - name: Start XVFB |
| run: Xvfb :99 & |
| - name: Start Fluxbox |
| run: fluxbox -display :99 & |
| - name: Run browser tests in Firefox (Remote) |
| uses: ./.github/actions/bazel |
| with: |
| command: test --jobs 1 //py:test-remote |
| env: |
| DISPLAY: :99 |
| |
| firefox_tests: |
| if: ${{ needs.check_workflow.outputs.result == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(toJson(github.event.commits), '[run python]') == true }} |
| needs: [ check_workflow, unit_tests ] |
| runs-on: ubuntu-latest |
| steps: |
| - name: Checkout source tree |
| uses: actions/checkout@v3 |
| - name: Cache Bazel artifacts |
| uses: actions/cache@v3 |
| with: |
| path: | |
| ~/.cache/bazel-disk |
| ~/.cache/bazel-repo |
| key: ${{ runner.os }}-bazel-firefox-tests-${{ hashFiles('**/BUILD.bazel') }} |
| restore-keys: | |
| ${{ runner.os }}-bazel-firefox-tests- |
| ${{ runner.os }}-bazel-python-unit-tests- |
| - name: Setup Fluxbox |
| run: sudo apt-get -y install fluxbox |
| - name: Setup Java |
| uses: actions/setup-java@v3 |
| with: |
| java-version: '11' |
| distribution: 'temurin' |
| - name: Setup Firefox |
| uses: abhi1693/setup-browser@v0.3.4 |
| with: |
| browser: firefox |
| version: latest |
| - name: Start Xvfb |
| run: Xvfb :99 & |
| - name: Start Fluxbox |
| run: fluxbox -display :99 & |
| - name: Run browser tests in Firefox |
| uses: ./.github/actions/bazel-test |
| with: |
| query: //py:test-firefox |
| attempts: 3 |
| env: |
| DISPLAY: :99 |
| |