-
Notifications
You must be signed in to change notification settings - Fork 7
128 lines (109 loc) · 3.84 KB
/
ci-lint-validate-convert.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: csvlinter
uses: kcheriyath/[email protected]
with:
find_pattern: "*.csv"
validate:
name: Validate CSV
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_check:
name: Check Component DependsOn entries
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
convert:
name: Convert CSV to JSON-LD
needs:
- lint
- validate
- component_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 }}