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

Commit 1301d96

Browse files
authored
fix: env: can be an expression (#21)
1 parent 7d1546b commit 1301d96

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

src/common/expr.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ impl ExplicitExpr {
4141
/// `${{ body }}`. Leading and trailing whitespace within
4242
/// the expression body is removed.
4343
pub fn as_bare(&self) -> &str {
44-
return self
45-
.as_curly()
44+
self.as_curly()
4645
.strip_prefix("${{")
4746
.and_then(|e| e.strip_suffix("}}"))
4847
.map(|e| e.trim())
49-
.expect("invariant violated: ExplicitExpr must be an expression");
48+
.expect("invariant violated: ExplicitExpr must be an expression")
5049
}
5150
}
5251

@@ -113,7 +112,7 @@ mod tests {
113112
#[test]
114113
fn test_expr() {
115114
let expr = "\" ${{ foo }} \\t \"";
116-
let expr: ExplicitExpr = serde_yaml::from_str(&expr).unwrap();
115+
let expr: ExplicitExpr = serde_yaml::from_str(expr).unwrap();
117116
assert_eq!(expr.as_bare(), "foo");
118117
}
119118

src/workflow/job.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub enum StepBody {
109109
working_directory: Option<String>,
110110
shell: Option<String>,
111111
#[serde(default)]
112-
env: Env,
112+
env: LoE<Env>,
113113
},
114114
}
115115

@@ -239,7 +239,7 @@ matrix:
239239
let runson = "group: \nlabels: []";
240240

241241
assert_eq!(
242-
serde_yaml::from_str::<RunsOn>(&runson)
242+
serde_yaml::from_str::<RunsOn>(runson)
243243
.unwrap_err()
244244
.to_string(),
245245
"runs-on must provide either `group` or one or more `labels`"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# https://raw.githubusercontent.com/jazzband/tablib/dcab406c553fc8b3c2e0aef955e9e8adea0590d8/.github/workflows/docs-lint.yml
2+
name: Docs and lint
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
env:
7+
FORCE_COLOR: 1
8+
PIP_DISABLE_PIP_VERSION_CHECK: 1
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
env:
19+
- TOXENV: docs
20+
- TOXENV: lint
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.x"
29+
cache: pip
30+
cache-dependency-path: "pyproject.toml"
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
python -m pip install --upgrade tox
36+
37+
- name: Tox
38+
run: tox
39+
env: ${{ matrix.env }}

tests/test_workflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn test_pip_audit_ci() {
6666
run,
6767
working_directory,
6868
shell,
69-
env,
69+
env: LoE::Literal(env),
7070
} = &test_job.steps[2].body
7171
else {
7272
panic!("expected run step");

0 commit comments

Comments
 (0)