|
1 | 1 | name: Check types |
2 | | -on: [pull_request] |
| 2 | +on: [workflow_call, workflow_dispatch] |
3 | 3 | env: |
4 | 4 | NODE_VERSION: '18' |
5 | | - PYTHON_VERSION: '3.9' |
6 | 5 |
|
7 | 6 | permissions: |
8 | 7 | contents: read |
9 | 8 |
|
10 | 9 | jobs: |
11 | 10 | typecheck: |
12 | 11 | runs-on: ubuntu-latest |
| 12 | + container: |
| 13 | + image: opendatacanada/ckan-pytest # primary executor |
13 | 14 | steps: |
14 | | - - uses: actions/checkout@v2 |
15 | | - id: gitcheckout |
16 | | - - uses: actions/setup-python@v2 |
17 | | - with: |
18 | | - python-version: ${{ env.PYTHON_VERSION }} |
19 | | - - uses: actions/setup-node@v3 |
| 15 | + - name: Install Node |
| 16 | + run: | |
| 17 | + apk add nodejs npm |
| 18 | + - uses: actions/setup-node@v4 |
20 | 19 | with: |
21 | 20 | node-version: ${{ env.NODE_VERSION }} |
22 | | - - name: Install python deps |
23 | | - id: pydepends |
24 | | - if: steps.gitcheckout.outcome == 'success' |
| 21 | + - name: Check Source Dependency Versions |
25 | 22 | run: | |
26 | | - python3 -m venv /home/runner/work/app |
27 | | - mkdir -p /home/runner/work/app/src/ckanext-recombinant |
28 | | - cp -R . /home/runner/work/app/src/ckanext-recombinant |
29 | | - source /home/runner/work/app/bin/activate |
30 | | - pip install --upgrade setuptools==70.0.0 |
31 | | - pip install --upgrade pip==23.2.1 |
32 | | - pip install -e 'git+https://github.com/open-data/ckan@canada-v2.10#egg=ckan' -r 'https://raw.githubusercontent.com/open-data/ckan/canada-v2.10/requirement-setuptools.txt' -r 'https://raw.githubusercontent.com/open-data/ckan/canada-v2.10/requirements.txt' -r 'https://raw.githubusercontent.com/open-data/ckan/canada-v2.10/dev-requirements.txt' |
33 | | - pip install -e 'git+https://github.com/ckan/ckanapi.git#egg=ckanapi' -r 'https://raw.githubusercontent.com/ckan/ckanapi/master/requirements.txt' |
34 | | - pip install -e /home/runner/work/app/src/ckanext-recombinant/. -r /home/runner/work/app/src/ckanext-recombinant/requirements.txt -r /home/runner/work/app/src/ckanext-recombinant/test-requirements.txt |
35 | | - pip install -e 'git+https://github.com/ckan/ckantoolkit.git#egg=ckantoolkit' -r 'https://raw.githubusercontent.com/ckan/ckantoolkit/master/requirements.txt' |
36 | | - find /home/runner/work/app -name '*.pyc' -delete |
37 | | - - name: Install node deps |
38 | | - if: steps.pydepends.outcome == 'success' |
| 23 | + source /srv/app/venv/bin/activate |
| 24 | + for dir in /srv/app/src/*; do |
| 25 | + srcName=$(echo "$dir" | awk -F'/' '{print $NF}'); |
| 26 | + if [[ -d "$dir/.git" ]]; then |
| 27 | + printf "${srcName}: Checking for updates..." |
| 28 | + cd $dir; |
| 29 | + current_branch=$(git rev-parse --abbrev-ref HEAD); |
| 30 | + if [[ "$srcName" == "ckan" ]]; then |
| 31 | + git fetch canada; |
| 32 | + reslog=$(git log HEAD..canada/$current_branch --oneline); |
| 33 | + else |
| 34 | + git fetch origin; |
| 35 | + reslog=$(git log HEAD..origin/$current_branch --oneline); |
| 36 | + fi; |
| 37 | + if [[ "${reslog}" == "" ]]; then |
| 38 | + printf "${srcName}: Up to date. Skipping..." |
| 39 | + else |
| 40 | + git pull || true; |
| 41 | + printf "${Green}${srcName}: Pulled updated code. Re-initializing in python environment..." |
| 42 | + cd /srv/app; |
| 43 | + if [[ -f "$dir/requirements.txt" ]]; then |
| 44 | + pip install -r $dir/requirements.txt || true; |
| 45 | + fi; |
| 46 | + if [[ -f "$dir/dev-requirements.txt" ]]; then |
| 47 | + pip install -r $dir/dev-requirements.txt || true; |
| 48 | + fi; |
| 49 | + if [[ -f "$dir/test-requirements.txt" ]]; then |
| 50 | + pip install -r $dir/test-requirements.txt || true; |
| 51 | + fi; |
| 52 | + if [[ -f "$dir/setup.py" ]]; then |
| 53 | + python $dir/setup.py develop || true; |
| 54 | + fi; |
| 55 | + fi; |
| 56 | + else |
| 57 | + printf "${srcName}: Not a source repository. Skipping..." |
| 58 | + fi; |
| 59 | + done; |
| 60 | + cd /srv/app; |
| 61 | + - name: Checkout Repository (${{ github.head_ref || github.ref_name }}) |
| 62 | + id: gitcheckout |
| 63 | + run: | |
| 64 | + cd /srv/app/src/ckanext-recombinant |
| 65 | + git fetch origin |
| 66 | + if [[ "${{ github.head_ref || github.ref_name }}" != "master" ]]; then |
| 67 | + git checkout -b ${{ github.head_ref || github.ref_name }} origin/${{ github.head_ref || github.ref_name }} |
| 68 | + fi; |
| 69 | + git fetch |
| 70 | + git pull |
| 71 | + source /srv/app/venv/bin/activate |
| 72 | + pip install -e . |
| 73 | + pip install -r requirements.txt |
| 74 | + pip install -r test-requirements.txt |
| 75 | + python3 setup.py develop |
| 76 | + cd /srv/app |
| 77 | + - name: Install Node Dependencies |
| 78 | + if: steps.gitcheckout.outcome == 'success' |
39 | 79 | run: | |
40 | | - cd /home/runner/work/app/src/ckanext-recombinant |
| 80 | + cd /srv/app/src/ckanext-recombinant |
41 | 81 | npm ci |
42 | | - - name: Check types |
43 | | - if: steps.pydepends.outcome == 'success' |
| 82 | + - name: Check Types |
| 83 | + if: steps.gitcheckout.outcome == 'success' |
44 | 84 | run: | |
45 | | - cd /home/runner/work/app/src/ckanext-recombinant |
| 85 | + export PYTHONPATH="${PYTHONPATH}:/srv/app/lib/python3.9/site-packages:/srv/app/src/ckanext-citeproc" |
| 86 | + source /srv/app/venv/bin/activate |
| 87 | + cd /srv/app/src/ckanext-recombinant |
46 | 88 | npx pyright |
0 commit comments