Update CI tests and add pre-commit #108
Workflow file for this run
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: Lint, validate and convert CSV to JSON-LD | |
on: | |
pull_request: | |
branches: 'main' | |
paths: 'HTAN.model.csv' | |
workflow_dispatch: | |
concurrency: | |
# cancel the current running workflow from the same branch, PR when a new workflow is triggered | |
# when the trigger is not a PR but a push, it will use the commit sha to generate the concurrency group | |
# {{ github.workflow }}: the workflow name is used to generate the concurrency group. This allows you to have more than one workflows | |
# {{ github.ref_type }}: the type of Git ref object created in the repository. Can be either branch or tag | |
# {{ github.sha }}: full commit sha | |
# credit: https://github.com/Sage-Bionetworks-Workflows/sagetasks/blob/main/.github/workflows/ci.yml | |
group: >- | |
${{ github.workflow }}-${{ github.ref_type }}- | |
${{ github.sha }} | |
cancel-in-progress: true | |
jobs: | |
lint: | |
name: Lint CSV | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: csvlinter | |
uses: kcheriyath/[email protected] | |
with: | |
find_pattern: "*.csv" | |
validate: | |
name: Validate CSV | |
if: always() | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install Schematic | |
shell: bash | |
run: | | |
pip3 install poetry | |
git clone --single-branch --branch main https://github.com/Sage-Bionetworks/schematic.git | |
cd schematic | |
poetry build | |
pip3 install dist/schematicpy-*-py3-none-any.whl | |
pip install --force-reinstall typing-extensions==4.5.0 | |
- name: Convert CSV schema | |
shell: bash | |
run: | | |
schematic schema convert .github/CSV.model.csv | |
- name: Validate data model CSV | |
shell: bash | |
run: | | |
schematic model -c .github/CSV_schematic_config.yml validate -mp HTAN.model.csv -dt "DataModel" | | |
grep "Your manifest has been validated successfully. There are no errors in your manifest, and it can be submitted without any modifications." | |
component_requirements_check: | |
name: Check component requirements | |
if: always() | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install Python dependencies | |
run: python -m pip install --upgrade pip pandas | |
- name: Run script | |
shell: bash | |
run: | | |
python .github/workflows/check_components.py | |
attributes_exist_check: | |
name: Check attributes exist | |
if: always() | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install Python dependencies | |
run: python -m pip install --upgrade pip pandas | |
- name: Run script | |
shell: bash | |
run: | | |
python .github/workflows/check_attributes_exist.py | |
attributes_used_check: | |
name: Check attributes are used | |
if: always() | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install Python dependencies | |
run: python -m pip install --upgrade pip pandas | |
- name: Run script | |
shell: bash | |
run: | | |
python .github/workflows/check_attributes_are_used.py | |
attributes_unique_check: | |
name: Check attributes are unique | |
if: always() | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install Python dependencies | |
run: python -m pip install --upgrade pip pandas | |
- name: Run script | |
shell: bash | |
run: | | |
python .github/workflows/check_attributes_are_unique.py | |
convert: | |
name: Convert CSV to JSON-LD | |
needs: | |
- lint | |
- validate | |
- component_requirements_check | |
- attributes_exist_check | |
- attributes_used_check | |
- attributes_unique_check | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install Schematic | |
shell: bash | |
run: | | |
pip3 install poetry | |
git clone --single-branch --branch main https://github.com/Sage-Bionetworks/schematic.git | |
cd schematic | |
poetry build | |
pip3 install dist/schematicpy-*-py3-none-any.whl | |
- name: Convert .csv to .jsonld | |
shell: bash | |
run: | | |
schematic schema convert HTAN.model.csv | |
- uses: r-lib/actions/pr-fetch@v2 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Commit the changes | |
run: | | |
git config --local user.name "$GITHUB_ACTOR" | |
git config --local user.email "[email protected]" | |
git add HTAN.model.jsonld | |
git commit -m "GitHub Action: convert *.model.csv to *.model.jsonld" || echo "No changes to commit" | |
- uses: r-lib/actions/pr-push@v2 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} |