Skip to content

Commit 2db07e3

Browse files
fix: check reqs exist (#1835)
* fix: check reqs * fix * docs: update README to reflect dependency needs
1 parent 78f372e commit 2db07e3

File tree

3 files changed

+132
-10
lines changed

3 files changed

+132
-10
lines changed

.github/workflows/main.yml

Lines changed: 108 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ jobs:
1414
- name: Checkout
1515
uses: actions/[email protected]
1616
with:
17-
submodules: 'true'
17+
submodules: "true"
1818
- name: Install dependencies
1919
run: pip install -r src/scripts/app/requirements.txt
2020
- name: Run tests and collect coverage
2121
run: pytest src/scripts/app/ --cov
22+
2223
- name: Upload coverage to Codecov (script)
2324
uses: ./
2425
with:
@@ -55,7 +56,7 @@ jobs:
5556
- name: Checkout
5657
uses: actions/[email protected]
5758
with:
58-
submodules: 'true'
59+
submodules: "true"
5960
- name: Install dependencies
6061
run: pip install -r src/scripts/app/requirements.txt
6162
- name: Run tests and collect coverage
@@ -104,32 +105,132 @@ jobs:
104105
- name: Checkout
105106
uses: actions/[email protected]
106107
with:
107-
submodules: 'true'
108+
submodules: "true"
108109
- name: Install deps
109110
run: |
110-
apt-get install git
111+
apt-get update && apt-get install -y git
112+
111113
- name: Upload coverage to Codecov (script)
112114
uses: ./
113115
with:
114116
files: ./coverage/script/coverage-final.json
115-
flags: script-${{ matrix.os }}
117+
flags: script-container
116118
name: codecov-script
117119
verbose: true
118120
token: ${{ secrets.CODECOV_TOKEN }}
119121
- name: Upload coverage to Codecov (demo)
120122
uses: ./
121123
with:
122124
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json
123-
flags: demo-${{ matrix.os }}
125+
flags: demo-container
124126
name: codecov-demo
125127
verbose: true
126128
token: ${{ secrets.CODECOV_TOKEN }}
127129
- name: Upload coverage to Codecov (version)
128130
uses: ./
129131
with:
130132
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json
131-
flags: version-${{ matrix.os }}
133+
flags: version-container
132134
name: codecov-version
133135
version: v9.1.0
134136
verbose: true
135137
token: ${{ secrets.CODECOV_TOKEN }}
138+
139+
run-alpine-missing-deps:
140+
runs-on: ubuntu-latest
141+
container: alpine:latest
142+
steps:
143+
- name: Install only some deps (missing gpg and bash)
144+
run: |
145+
apk add git
146+
- name: Checkout
147+
uses: actions/[email protected]
148+
with:
149+
submodules: "true"
150+
- name: Upload coverage to Codecov (should fail due to missing dependencies)
151+
id: codecov-upload
152+
continue-on-error: true
153+
uses: ./
154+
with:
155+
files: ./coverage/script/coverage-final.json
156+
flags: script-alpine-missing-deps
157+
name: codecov-script
158+
verbose: true
159+
token: ${{ secrets.CODECOV_TOKEN }}
160+
- name: Verify dependency check failed
161+
run: |
162+
if [ "${{ steps.codecov-upload.outcome }}" = "failure" ]; then
163+
echo "✓ Action correctly failed due to missing dependencies"
164+
exit 0
165+
else
166+
echo "✗ Action should have failed but didn't"
167+
exit 1
168+
fi
169+
170+
run-alpine-success:
171+
runs-on: ubuntu-latest
172+
container: alpine:latest
173+
steps:
174+
- name: Install all required deps
175+
run: |
176+
apk add git curl gnupg bash
177+
- name: Checkout
178+
uses: actions/[email protected]
179+
with:
180+
submodules: "true"
181+
- name: Upload coverage to Codecov (should succeed)
182+
uses: ./
183+
with:
184+
files: ./coverage/script/coverage-final.json
185+
flags: script-alpine-success
186+
name: codecov-script
187+
verbose: true
188+
token: ${{ secrets.CODECOV_TOKEN }}
189+
- name: Upload coverage to Codecov (demo)
190+
uses: ./
191+
with:
192+
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json
193+
flags: demo-alpine-success
194+
name: codecov-demo
195+
verbose: true
196+
token: ${{ secrets.CODECOV_TOKEN }}
197+
- name: Upload coverage to Codecov (version)
198+
uses: ./
199+
with:
200+
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json
201+
flags: version-alpine-success
202+
name: codecov-version
203+
version: v9.1.0
204+
verbose: true
205+
token: ${{ secrets.CODECOV_TOKEN }}
206+
207+
run-alpine-partial-deps:
208+
runs-on: ubuntu-latest
209+
container: alpine:latest
210+
steps:
211+
- name: Install only some deps (missing gpg and bash)
212+
run: |
213+
apk add git curl
214+
- name: Checkout
215+
uses: actions/[email protected]
216+
with:
217+
submodules: "true"
218+
- name: Upload coverage to Codecov (should fail due to missing gpg and bash)
219+
id: codecov-upload
220+
continue-on-error: true
221+
uses: ./
222+
with:
223+
files: ./coverage/script/coverage-final.json
224+
flags: script-alpine-partial-deps
225+
name: codecov-script
226+
verbose: true
227+
token: ${{ secrets.CODECOV_TOKEN }}
228+
- name: Verify dependency check failed
229+
run: |
230+
if [ "${{ steps.codecov-upload.outcome }}" = "failure" ]; then
231+
echo "✓ Action correctly failed due to missing dependencies (gpg and bash)"
232+
exit 0
233+
else
234+
echo "✗ Action should have failed but didn't"
235+
exit 1
236+
fi

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ You can see their usage in the `action.yml` [file](https://github.com/codecov/co
4949

5050
## Usage
5151

52+
> [!CAUTION]
53+
> In order for the Action to work seamlessly, you will need to have `bash`, `curl`, `git`, and `gpg` installed on your runner. You will also need to run [actions/checkout](https://github.com/actions/checkout) before calling the Codecov action. If these are not present, the Action will fail. Github Actions runners will have these installed by default. If you are using a custom runner or running in a container, you will need to ensure that these are installed.
54+
5255
To integrate Codecov with your Actions pipeline, specify the name of this repository with a tag number (`@v5` is recommended) as a `step` within your `workflow.yml` file.
5356

54-
> [!WARNING]
55-
> In order for the Action to work seamlessly, you will need to have `curl`, `git`, and `gpg` installed on your runner. You will also need to run the [actions/checkout](https://github.com/actions/checkout) before calling the Codecov action.
5657

5758
This Action also requires you to [provide an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) from [codecov.io](https://www.codecov.io) (tip: in order to avoid exposing your token, [store it](https://docs.codecov.com/docs/adding-the-codecov-token#github-actions) as a `secret`).
5859

@@ -96,7 +97,7 @@ steps:
9697
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
9798
```
9899
99-
> [!NOTE]
100+
> [!IMPORTANT]
100101
> This assumes that you've set your Codecov token inside _Settings > Secrets_ as `CODECOV_TOKEN`. If not, you can [get an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) for your specific repo on [codecov.io](https://www.codecov.io). Keep in mind that secrets are _not_ available to forks of repositories.
101102

102103
### Using OIDC

action.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,26 @@ branding:
175175
runs:
176176
using: "composite"
177177
steps:
178+
- name: Check system dependencies
179+
shell: sh
180+
run: |
181+
missing_deps=""
182+
183+
# Check for required commands
184+
for cmd in bash git curl gpg; do
185+
if ! command -v "$cmd" >/dev/null 2>&1; then
186+
missing_deps="$missing_deps $cmd"
187+
fi
188+
done
189+
190+
# Report missing required dependencies
191+
if [ -n "$missing_deps" ]; then
192+
echo "Error: The following required dependencies are missing:$missing_deps"
193+
echo "Please install these dependencies before using this action."
194+
exit 1
195+
fi
196+
197+
echo "All required system dependencies are available."
178198
- name: Action version
179199
shell: bash
180200
run: |

0 commit comments

Comments
 (0)