Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit f924282

Browse files
authored
fix: allow env values to be empty/null (#10)
1 parent 3be7235 commit f924282

File tree

4 files changed

+83
-5
lines changed

4 files changed

+83
-5
lines changed

src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub enum Permission {
5555
}
5656

5757
/// An environment mapping.
58-
pub type Env = HashMap<String, EnvValue>;
58+
pub type Env = HashMap<String, Option<EnvValue>>;
5959

6060
/// Environment variable values are always strings, but GitHub Actions
6161
/// allows users to configure them as various native YAML types before

src/workflow/job.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ mod tests {
176176
let Secrets::Env(secrets) = serde_yaml::from_str::<Secrets>(secrets).unwrap() else {
177177
panic!("unexpected secrets variant");
178178
};
179-
assert_eq!(secrets["foo-secret"], EnvValue::String("bar".into()));
179+
assert_eq!(
180+
secrets["foo-secret"].as_ref().unwrap(),
181+
&EnvValue::String("bar".into())
182+
);
180183
}
181184

182185
#[test]
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# https://github.com/adafruit/circuitpython/blob/24a8927d0ce1d77addd584bf809ab73cb0386e75/.github/workflows/run-tests.yml
2+
name: Run tests
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
cp-version:
8+
required: true
9+
type: string
10+
11+
jobs:
12+
run:
13+
runs-on: ubuntu-24.04
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
test: [all, mpy, native, native_mpy]
18+
env:
19+
CP_VERSION: ${{ inputs.cp-version }}
20+
MICROPY_CPYTHON3: python3.12
21+
MICROPY_MICROPYTHON: ../ports/unix/build-coverage/micropython
22+
TEST_all:
23+
TEST_mpy: --via-mpy -d basics float micropython
24+
TEST_native: --emit native
25+
TEST_native_mpy: --via-mpy --emit native -d basics float micropython
26+
steps:
27+
- name: Set up repository
28+
uses: actions/checkout@v4
29+
with:
30+
submodules: false
31+
show-progress: false
32+
fetch-depth: 1
33+
- name: Set up python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: 3.12
37+
- name: Set up submodules
38+
uses: ./.github/actions/deps/submodules
39+
with:
40+
target: tests
41+
- name: Set up external
42+
if: matrix.test == 'all'
43+
uses: ./.github/actions/deps/external
44+
- name: Set up mpy-cross
45+
uses: ./.github/actions/mpy_cross
46+
with:
47+
cp-version: ${{ inputs.cp-version }}
48+
- name: Build unix port
49+
run: make -C ports/unix VARIANT=coverage -j4
50+
- name: Run tests
51+
run: ./run-tests.py -j4 ${{ env[format('TEST_{0}', matrix.test)] }}
52+
working-directory: tests
53+
- name: Print failure info
54+
run: ./run-tests.py -j4 --print-failures
55+
if: failure()
56+
working-directory: tests
57+
# Not working after MicroPython v1.23 merge.
58+
# - name: Build native modules
59+
# if: matrix.test == 'all'
60+
# run: |
61+
# make -C examples/natmod/features1
62+
# make -C examples/natmod/features2
63+
# make -C examples/natmod/heapq
64+
# make -C examples/natmod/random
65+
# make -C examples/natmod/re
66+
# - name: Test native modules
67+
# if: matrix.test == 'all'
68+
# run: ./run-natmodtests.py extmod/{heapq*,random*,re*}.py
69+
# working-directory: tests

tests/test_workflow.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ fn test_pip_audit_ci() {
5555
panic!("expected uses step");
5656
};
5757
assert_eq!(uses, "actions/setup-python@v5");
58-
assert_eq!(with["python-version"].to_string(), "${{ matrix.python }}");
59-
assert_eq!(with["cache"].to_string(), "pip");
60-
assert_eq!(with["cache-dependency-path"].to_string(), "pyproject.toml");
58+
assert_eq!(
59+
with["python-version"].as_ref().unwrap().to_string(),
60+
"${{ matrix.python }}"
61+
);
62+
assert_eq!(with["cache"].as_ref().unwrap().to_string(), "pip");
63+
assert_eq!(
64+
with["cache-dependency-path"].as_ref().unwrap().to_string(),
65+
"pyproject.toml"
66+
);
6167

6268
let StepBody::Run {
6369
run,

0 commit comments

Comments
 (0)