Merge pull request #405 from nitsanavni/add-ci

add ci - start with jq
This commit is contained in:
Emily Bache 2023-02-08 08:30:44 +01:00 committed by GitHub
commit 820e796fd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 3 deletions

39
.github/workflows/jq.yml vendored Normal file
View File

@ -0,0 +1,39 @@
name: jq
on:
pull_request:
branches:
- main
paths:
- jq/*
jobs:
test-jq-translation:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Rust Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# TODO: this step takes ~2m, consider using https://github.com/marketplace/actions/cargo-install
- name: Install jaq
run: |
cargo install --locked --git https://github.com/01mf02/jaq
- name: Expect unit test to fail
working-directory: jq
run: |
! ./test-gilded-rose.sh
- name: Expect texttest fixture output (aka 'verify')
working-directory: jq
run: |
jaq --arg days 31 -nr "$(cat gilded-rose.jq) $(cat texttest_fixture.jq)" |
diff - ../texttests/ThirtyDays/stdout.gr

View File

@ -5,7 +5,7 @@
{ name: "Aged Brie", sell_in: 2, quality: 0 },
{ name: "Elixir of the Mongoose", sell_in: 5, quality: 7 },
{ name: "Sulfuras, Hand of Ragnaros", sell_in: 0, quality: 80 },
{ name: "Sulfuras, Hand of Ragnaros", sell_in: 1, quality: 80 },
{ name: "Sulfuras, Hand of Ragnaros", sell_in: -1, quality: 80 },
{ name: "Backstage passes to a TAFKAL80ETC concert", sell_in: 15, quality: 20 },
{ name: "Backstage passes to a TAFKAL80ETC concert", sell_in: 10, quality: 49 },
{ name: "Backstage passes to a TAFKAL80ETC concert", sell_in: 5, quality: 49 },
@ -14,9 +14,9 @@
{ items: ., day: 0 } |
recurse(.day += 1 | .items = (.items | update_quality); .day < ($ARGS.named.days // 2 | tonumber)) |
(
"",
(["-------- day ", (.day | tostring), " --------"] | add),
("name, sellIn, quality"),
(.items[] | [.name, .sell_in, .quality | tostring] | join(", "))
(.items[] | [.name, .sell_in, .quality | tostring] | join(", ")),
""
)
)