Test #429
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: Test | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
schedule: | |
- cron: "0 5 * * *" | |
# Cancel previous runs that have not completed | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
env: | |
# Location of RCLONE configuration file | |
RCLONE_CONFIG: ci/rclone.conf | |
# Path & URL fragments for uploaded historical data & diagnostics | |
gcs_bucket: gcs:data.transportenergy.org/historical/ci/ | |
gcs_url: https://storage.googleapis.com/data.transportenergy.org/historical/ci/ | |
jobs: | |
pytest: | |
strategy: | |
matrix: | |
os: | |
- macos-latest | |
- ubuntu-latest | |
- windows-latest | |
version: | |
- { python: "3.8", others: "" } | |
# Pint 0.24 with numpy 2.0 compatibility is not available for Python 3.9. | |
# Use earlier numpy to be compatible with pint < 0.24. | |
- { python: "3.9", others: "'numpy < 2'" } | |
- { python: "3.10", others: "" } | |
- { python: "3.11", others: "" } | |
- { python: "3.12", others: "" } | |
# TEMPORARY Never run diagnostics | |
run-diagnostics: | |
- false | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
name: ${{ matrix.os }}-py${{ matrix.version.python }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.version.python }} | |
cache: pip | |
cache-dependency-path: "**/pyproject.toml" | |
- name: Upgrade pip | |
run: python -m pip install --upgrade pip | |
- name: Install the Python package and its dependencies | |
run: pip install .[tests] ${{ matrix.version.others }} | |
- name: Run pytest | |
env: | |
OK_API_KEY: ${{ secrets.OPENKAPSARC_API_KEY }} | |
run: pytest --color=yes --cov-report=xml --verbose item | |
- name: Upload test coverage to Codecov.io | |
uses: codecov/codecov-action@v5 | |
with: { token: "${{ secrets.CODECOV_TOKEN }}" } | |
diagnostics: | |
# Temporarily disabled to merge #84 | |
if: false | |
# True if the event is a pull request and the incoming branch is within the | |
# transportenergy/database repo (as opposed to a fork). Only under this | |
# condition is the GCS_SERVICE_ACCOUNT_* secret available. | |
# if: github.event_name != 'pull_request' || startsWith(github.event.pull_request.head.label, 'transportenergy:') | |
needs: [pytest] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/setup-python@v5 | |
with: # Should be the same as the latest supported version, above | |
python-version: "3.12" | |
cache: pip | |
cache-dependency-path: "**/pyproject.toml" | |
- name: Upgrade pip | |
run: python -m pip install --upgrade pip | |
- name: Install the Python package and its dependencies | |
run: pip install .[tests] | |
- name: Set up Rclone | |
uses: AnimMouse/setup-rclone@v1 | |
- name: Create diagnostics and upload to Google Cloud Storage | |
env: | |
service_account_json: ${{ secrets.GCS_SERVICE_ACCOUNT_1 }} | |
run: | | |
echo "$service_account_json" >ci/service-account-key.json | |
item historical diagnostics output/ | |
rclone --progress copy output ${{ env.gcs_bucket }}${{ github.run_id }}/ | |
- uses: LouisBrunner/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
name: Upload historical database & diagnostics | |
conclusion: success | |
details_url: ${{ env.gcs_url }}${{ github.run_id }}/index.html | |
output: | | |
{"summary": "${{ env.gcs_url }}${{ github.run_id }}/index.html"} | |
pre-commit: | |
name: Code quality | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: { python-version: 3.x } | |
- name: Force recreation of pre-commit virtual environment for mypy | |
if: github.event_name == 'schedule' # Comment this line to run on a PR | |
run: gh cache list -L 999 | cut -f2 | grep pre-commit | xargs -I{} gh cache delete "{}" || true | |
env: { GH_TOKEN: "${{ github.token }}" } | |
- uses: pre-commit/[email protected] |