Skip to content

Commit 034362a

Browse files
committed
Fix python things
Signed-off-by: Alex Lourie <alex.lourie@zepben.com>
1 parent e3e0e8c commit 034362a

2 files changed

Lines changed: 98 additions & 81 deletions

File tree

.github/workflows/python-build.yml

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,16 @@ jobs:
5959
echo -e "${message}" | gh pr comment ${{ github.event.pull_request.number }} --body-file -
6060
fi
6161
62-
build-and-test:
62+
run-checks:
6363
runs-on: ubuntu-latest
64-
container: python:3.10
6564
env:
6665
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
6766
outputs:
6867
docs-present: ${{ steps.docs.outputs.present }}
69-
steps:
70-
- uses: actions/checkout@v4
7168

72-
- name: Install system dependencies
73-
run: |
74-
apt install gh jq
69+
steps:
7570

76-
- name: Install dependencies
77-
run: |
78-
pip install tox
71+
- uses: actions/checkout@v4
7972

8073
- name: Work around git permission issue
8174
run: |
@@ -95,18 +88,6 @@ jobs:
9588
LC_URL: ${{ secrets.LC_URL }}
9689
PATH: ${{ inputs.sourcepath }}
9790

98-
- name: Build and test
99-
run: |
100-
tox
101-
shell: bash
102-
103-
- name: Upload coverage to Codecov
104-
uses: codecov/codecov-action@v4
105-
with:
106-
fail_ci_if_error: false
107-
token: ${{ secrets.CODECOV_TOKEN }}
108-
continue-on-error: true
109-
11091
- name: Check if docs present
11192
id: docs
11293
run: |
@@ -130,23 +111,46 @@ jobs:
130111
run: |
131112
# Make sure directories are properly ignored
132113
# docs/node_modules
133-
git check-ignore -q docs/node_modules
114+
git check-ignore -q docs/site-config/project.json
134115
if [ $? != 0 ]; then
135-
echo "ERROR! Make sure to add 'docs/node_modules' to .gitignore"
136-
echo "::error line=1::ERROR! Make sure to add 'docs/node_modules' to .gitignore"
116+
echo "ERROR! Make sure to add 'docs/site-config' to .gitignore"
117+
echo "::error line=1::ERROR! Make sure to add 'docs/site-config' to .gitignore"
137118
exit 1
138119
fi
139120
140-
# docs/build
141-
git check-ignore -q docs/build
142-
if [ $? != 0 ]; then
143-
echo "ERROR! Make sure to add 'docs/build' to .gitignore"
144-
echo "::error line=1::ERROR! Make sure to add 'docs/build' to .gitignore"
145-
exit 1
146-
fi
121+
build-and-test:
122+
runs-on: ubuntu-latest
123+
container: python:3.10
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
126+
127+
steps:
128+
- uses: actions/checkout@v4
129+
130+
- name: Install dependencies
131+
run: |
132+
pip install tox
133+
134+
- name: Work around git permission issue
135+
run: |
136+
dname=$(echo ${{github.repository}} | cut -d'/' -f2)
137+
git config --global --add safe.directory /__w/$dname/$dname
138+
shell: sh
139+
140+
- name: Build and test
141+
run: |
142+
tox
143+
shell: bash
144+
145+
- name: Upload coverage to Codecov
146+
uses: codecov/codecov-action@v4
147+
with:
148+
fail_ci_if_error: false
149+
token: ${{ secrets.CODECOV_TOKEN }}
150+
continue-on-error: true
147151

148152
build-docs:
149-
needs: [build-and-test]
150-
if: ${{ needs.build-and-test.outputs.docs-present == 'yes' }}
153+
needs: [run-checks]
154+
if: ${{ needs.run-checks.outputs.docs-present == 'yes' }}
151155
uses: ./.github/workflows/build-docs.yaml
152156
secrets: inherit

.github/workflows/python-lib-snapshot.yml

Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,17 @@ on:
3030
required: false
3131

3232
jobs:
33-
deploy:
33+
34+
run-checks:
3435
runs-on: ubuntu-latest
35-
container: python:3.10
3636
env:
3737
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
38-
outputs:
38+
outputs:
3939
docs-present: ${{ steps.docs.outputs.present }}
40-
# permissions: # Uncomment these when trusted publishing supports reusable workflows OPS-185
41-
# id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
42-
steps:
43-
- uses: actions/checkout@v4
4440

45-
- name: Install system dependencies
46-
run: |
47-
apt install gh jq
41+
steps:
4842

49-
- name: Install dependencies
50-
run: |
51-
pip install tox twine
43+
- uses: actions/checkout@v4
5244

5345
- name: Work around git permission issue
5446
run: |
@@ -66,7 +58,59 @@ jobs:
6658
uses: zepben/licence-check-action@main
6759
with:
6860
LC_URL: ${{ secrets.LC_URL }}
69-
PATH: src
61+
PATH: ${{ inputs.sourcepath }}
62+
63+
- name: Check if docs present
64+
id: docs
65+
run: |
66+
if [ -d docs ]; then
67+
echo "Docs folder found, will run the build-docs job"
68+
echo "present=yes" >> "${GITHUB_OUTPUT}"
69+
echo "present=yes" >> "${GITHUB_ENV}"
70+
else
71+
echo "Docs folder not found, will skip the build-docs"
72+
fi
73+
74+
- name: Work around git permission issue
75+
run: |
76+
dname=$(echo ${{github.repository}} | cut -d'/' -f2)
77+
git config --global --add safe.directory /__w/$dname/$dname
78+
shell: sh
79+
80+
- name: Check doc build artifacts are ignored
81+
if: ${{ env.present == 'yes' }}
82+
shell: sh {0}
83+
run: |
84+
# Make sure directories are properly ignored
85+
# docs/node_modules
86+
git check-ignore -q docs/site-config/project.json
87+
if [ $? != 0 ]; then
88+
echo "ERROR! Make sure to add 'docs/site-config' to .gitignore"
89+
echo "::error line=1::ERROR! Make sure to add 'docs/site-config' to .gitignore"
90+
exit 1
91+
fi
92+
93+
deploy:
94+
runs-on: ubuntu-latest
95+
container: python:3.10
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
98+
outputs:
99+
docs-present: ${{ steps.docs.outputs.present }}
100+
# permissions: # Uncomment these when trusted publishing supports reusable workflows OPS-185
101+
# id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
102+
steps:
103+
- uses: actions/checkout@v4
104+
105+
- name: Install dependencies
106+
run: |
107+
pip install tox twine
108+
109+
- name: Work around git permission issue
110+
run: |
111+
dname=$(echo ${{github.repository}} | cut -d'/' -f2)
112+
git config --global --add safe.directory /__w/$dname/$dname
113+
shell: sh
70114

71115
- name: Create .pypirc
72116
env:
@@ -100,37 +144,6 @@ jobs:
100144
token: ${{ secrets.CODECOV_TOKEN }}
101145
continue-on-error: true
102146

103-
- name: Check if docs present
104-
id: docs
105-
run: |
106-
if [ -d docs ]; then
107-
echo "Docs folder found, will run the build-docs job"
108-
echo "present=yes" >> "${GITHUB_OUTPUT}"
109-
echo "present=yes" >> "${GITHUB_ENV}"
110-
else
111-
echo "Docs folder not found, will skip the build-docs"
112-
fi
113-
114-
- name: Work around git permission issue
115-
run: |
116-
dname=$(echo ${{github.repository}} | cut -d'/' -f2)
117-
git config --global --add safe.directory /__w/$dname/$dname
118-
shell: sh
119-
120-
- name: Check doc build artifacts are ignored
121-
if: ${{ env.present == 'yes' }}
122-
shell: sh {0}
123-
run: |
124-
# Make sure directories are properly ignored
125-
# docs/node_modules
126-
git check-ignore -q docs/site-config/project.json
127-
if [ $? != 0 ]; then
128-
echo "ERROR! Make sure to add 'docs/site-config' to .gitignore"
129-
echo "::error line=1::ERROR! Make sure to add 'docs/site-config' to .gitignore"
130-
exit 1
131-
fi
132-
133-
134147
update-snapshot-version:
135148
needs: [deploy]
136149
container: zepben/pipeline-basic
@@ -155,8 +168,8 @@ jobs:
155168
shell: bash
156169

157170
build-docs:
158-
needs: [deploy]
159-
if: ${{ needs.deploy.outputs.docs-present == 'yes' }}
171+
needs: [run-checks]
172+
if: ${{ needs.run-checks.outputs.docs-present == 'yes' }}
160173
uses: ./.github/workflows/build-docs.yaml
161174
with:
162175
DEPLOY: true

0 commit comments

Comments
 (0)