Skip to content

Commit

Permalink
feat: enable prettier for scenarios (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
samypr100 authored Oct 7, 2024
1 parent 44c1016 commit 70abfe8
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 49 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ jobs:
- name: Check Python formatting
run: uvx ruff format --check . --config pyproject.toml

- name: Check Scenarios formatting
run: |
npm ci
npx prettier --check "scenarios/**/*.{toml,json,yaml}"
typos:
runs-on: ubuntu-latest
name: Check typos
Expand Down
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["prettier-plugin-toml"]
}
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,12 @@ manually back out the change. See [this comment][index-incorrect-snapshot] for
an example.

[index-incorrect-snapshot]: https://github.com/astral-sh/packse/pull/175#issuecomment-2056964089

## Formatting Scenarios

This step requires NodeJS installed.

```
npm install
npx prettier --write "scenarios/**/*.{toml,json,yaml}"
```
65 changes: 65 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"devDependencies": {
"prettier": "^3.3.3",
"prettier-plugin-toml": "^2.0.1"
}
}
60 changes: 27 additions & 33 deletions scenarios/examples/example.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,33 @@
{
"name": "example",
"description": "This is an example scenario, in which the user depends on a single package `a` which requires `b`.",
"expected": {
"satisfiable": true,
"packages": {
"a": "1.0.0",
"b": "2.0.0"
},
"explanation": "The latest valid version of `b` should be installed. `b==3.0.0` is not valid because it requires `c` which does not exist."
"name": "example",
"description": "This is an example scenario, in which the user depends on a single package `a` which requires `b`.",
"expected": {
"satisfiable": true,
"packages": {
"a": "1.0.0",
"b": "2.0.0"
},
"root": {
"requires": [
"a"
]
"explanation": "The latest valid version of `b` should be installed. `b==3.0.0` is not valid because it requires `c` which does not exist."
},
"root": {
"requires": ["a"]
},
"packages": {
"a": {
"versions": {
"1.0.0": {
"requires": ["b>1.0.0"]
}
}
},
"packages": {
"a": {
"versions": {
"1.0.0": {
"requires": [
"b>1.0.0"
]
}
}
},
"b": {
"versions": {
"1.0.0": {},
"2.0.0": {},
"3.0.0": {
"requires": [
"c"
]
}
}
"b": {
"versions": {
"1.0.0": {},
"2.0.0": {},
"3.0.0": {
"requires": ["c"]
}
}
}
}
}
18 changes: 9 additions & 9 deletions scenarios/examples/example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ description = "This is an example scenario written in TOML, in which the user de
satisfiable = true
explanation = "The latest valid version of `b` should be installed. `b==3.0.0` is not valid because it requires `c` which does not exist."

[expected.packages]
a = "1.0.0"
b = "2.0.0"
[expected.packages]
a = "1.0.0"
b = "2.0.0"

[root]
requires = [ "a" ]
requires = ["a"]

[packages.a.versions."1.0.0"]
requires = [ "b>1.0.0" ]
requires = ["b>1.0.0"]

[packages.b.versions]
"1.0.0" = { }
"2.0.0" = { }
"1.0.0" = {}
"2.0.0" = {}

[packages.b.versions."3.0.0"]
requires = [ "c" ]
[packages.b.versions."3.0.0"]
requires = ["c"]
16 changes: 9 additions & 7 deletions scenarios/examples/example.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
- name: example-yaml
description: This is an example scenario written in YAML, in which the user depends on a single
package `a` which requires `b`.
description:
This is an example scenario written in YAML, in which the user depends on a
single package `a` which requires `b`.
expected:
satisfiable: true
packages:
a: 1.0.0
b: 2.0.0
explanation: The latest valid version of `b` should be installed. `b==3.0.0` is
not valid because it requires `c` which does not exist.
explanation:
The latest valid version of `b` should be installed. `b==3.0.0` is not
valid because it requires `c` which does not exist.
root:
requires:
- a
- a
packages:
a:
versions:
1.0.0:
requires:
- b>1.0.0
- b>1.0.0
b:
versions:
1.0.0: {}
2.0.0: {}
3.0.0:
requires:
- c
- c

0 comments on commit 70abfe8

Please sign in to comment.