Skip to content

Workflow file for this run

name: Test suite & diagnostics
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: "0 5 * * *"
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/
# 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.
pr_from_main_repo: github.event_name != 'pull_request' || startsWith(github.event.pull_request.head.label, 'transportenergy:')
jobs:
pytest:
strategy:
matrix:
include:
- os: ubuntu-latest
python-version: "3.7"
run-diagnostics: false
- os: ubuntu-latest
python-version: "3.8"
run-diagnostics: false
- os: ubuntu-latest
python-version: "3.9"
run-diagnostics: true
- os: windows-latest
python-version: "3.9"
run-diagnostics: false
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }}-py${{ matrix.python-version }}
steps:
- name: Cancel previous runs that have not completed
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache Python packages
uses: actions/cache@v2
with:
path: |
~/.cache/pip
~/.cache/rclone*.zip
~/appdata/local/pip/cache
key: ${{ matrix.os }}-${{ matrix.python-version }}
- name: Upgrade pip, wheel
run: python -m pip install --upgrade pip wheel
- name: Install the Python package and dependencies
run: pip install --editable .[tests]
- 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@v1
- name: Install rclone
if: env.pr_from_main_repo && matrix.run-diagnostics
env:
service_account_json: ${{ secrets.GCS_SERVICE_ACCOUNT_1 }}
run: |
mkdir -p $HOME/.cache
pushd $HOME/.cache
curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip
popd
unzip $HOME/.cache/rclone-current-linux-amd64.zip
ls -d rclone-v* > $GITHUB_PATH
echo "$service_account_json" >ci/service-account-key.json
- name: Create diagnostics and upload to Google Cloud Storage
if: env.pr_from_main_repo && matrix.run-diagnostics
run: |
item historical diagnostics output/
rclone --progress copy output ${{ env.gcs_bucket }}${{ github.run_id }}/
- uses: LouisBrunner/[email protected]
if: env.pr_from_main_repo && matrix.run-diagnostics
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"}