Skip to content

run script

run script #458

Workflow file for this run

name: OpenData Testing
on:
push:
pull_request:
workflow_dispatch:
inputs:
ods_tools_branch:
description: "Build ODS tools package for tests: [git ref]"
required: false
env:
ods_tools_branch: ${{ github.event_name != 'workflow_dispatch' && 'main' || inputs.ods_tools_branch }}
jobs:
build_spec:
uses: ./.github/workflows/build.yml
secrets: inherit
build_package:
needs: build_spec
uses: OasisLMF/ODS_Tools/.github/workflows/build.yml@main
secrets: inherit
with:
oed_spec_json: ${{ needs.build_spec.outputs.json_filename }}
ods_branch: ${{ github.event_name != 'workflow_dispatch' && 'main' || inputs.ods_tools_branch }}
attach_pr:
if: github.event_name == 'pull_request'
name: Update PR
needs: build_spec
runs-on: ubuntu-latest
steps:
- name: Github context
run: echo "$GITHUB_CONTEXT"
shell: bash
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Get Artifact URL & PR Info
env:
GITHUB_TOKEN: ${{ github.token }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
JOB_ID: ${{ github.run_id }}
PR_NUMBER: ${{ github.event.number }}
HEAD_SHA: ${{ github.sha }}
run: |
echo "Job ID: $JOB_ID"
echo "JOB_ID=$JOB_ID" >> "$GITHUB_ENV"
EXCEL_ID=$(gh api "/repos/OasisLMF/ODS_OpenExposureData/actions/artifacts" --jq '.artifacts[] | select(.workflow_run.id == '$JOB_ID') | select(.expired == false) | select(.name | startswith("excel_spec")) | .id')
echo "EXCEL ID: $EXCEL_ID"
echo "EXCEL_ID=$EXCEL_ID" >> "$GITHUB_ENV"
JSON_ID=$(gh api "/repos/OasisLMF/ODS_OpenExposureData/actions/artifacts" --jq '.artifacts[] | select(.workflow_run.id == '$JOB_ID') | select(.expired == false) | select(.name | startswith("extracted_spec")) | .id')
echo "JSON ID: $JSON_ID"
echo "JSON_ID=$JSON_ID" >> "$GITHUB_ENV"
echo "PR Number: $PR_NUMBER"
echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV"
echo "Head sha: $HEAD_SHA"
echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV"
- name: Update Comment
env:
JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/\
runs/${{ env.JOB_ID }}"
HEAD_SHA: ${{ env.HEAD_SHA }}
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ env.PR_NUMBER }}
body: |-
## Build Preview
You can find files attached to the below linked Workflow Run URL (Logs).
Please note that files only stay for around 14 days!
| Name | Link
------------|-------------------------------------------------------
| Commit | ${{ env.HEAD_SHA }}
| Build | ${{ env.JOB_PATH }}
| Excel File | [excel_spec.zip](https://github.com/OasisLMF/ODS_OpenExposureData/actions/runs/${{ env.JOB_ID }}/artifacts/${{ env.EXCEL_ID }})
| JSON File | [extracted_spec.zip](https://github.com/OasisLMF/ODS_OpenExposureData/actions/runs/${{ env.JOB_ID }}/artifacts/${{ env.JSON_ID }})
[badge]: https://img.shields.io/badge/Build-Success!-3fb950?logo=github&style=for-the-badge
test:
name: Run Pytest
runs-on: ubuntu-latest
needs: build_package
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- name: Clone ODS_Tools repo
uses: actions/checkout@v3
with:
repository: Oasislmf/ODS_Tools
ref: ${{ env.ods_tools_branch }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Download package
uses: actions/download-artifact@v4
with:
name: bin_package
path: ${{ github.workspace }}/
- name: install package
run: pip install ${{ needs.build_package.outputs.whl_filename }}
- name: Install test deps
run: pip install -r tests/requirements.in
- name: Run tests
run: pytest -v