From 6527ea8bc33d43e3424d2f74f464e747cbc386f9 Mon Sep 17 00:00:00 2001 From: Nitsan Avni Date: Tue, 7 Feb 2023 12:31:13 +0000 Subject: [PATCH 1/6] add jq.yml workflow --- .github/workflows/jq.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/jq.yml diff --git a/.github/workflows/jq.yml b/.github/workflows/jq.yml new file mode 100644 index 00000000..dba90401 --- /dev/null +++ b/.github/workflows/jq.yml @@ -0,0 +1,30 @@ +name: jq + +on: + pull_request: + branches: + - main + paths: + - jq/* + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Rust + uses: actions/setup-rust@v1 + with: + rust-version: stable + + - name: Install jaq + run: | + cargo install --locked --git https://github.com/01mf02/jaq + + - name: Run tests on jq directory + working-directory: jq + run: | + ./test-gilded-rose.sh From f98299285041ad0b0e67f2984fefe2f1c6ccada2 Mon Sep 17 00:00:00 2001 From: Nitsan Avni Date: Tue, 7 Feb 2023 12:39:03 +0000 Subject: [PATCH 2/6] diff action --- .github/workflows/jq.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jq.yml b/.github/workflows/jq.yml index dba90401..12a99f13 100644 --- a/.github/workflows/jq.yml +++ b/.github/workflows/jq.yml @@ -15,10 +15,11 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Set up Rust - uses: actions/setup-rust@v1 + - uses: actions-rs/toolchain@v1 with: - rust-version: stable + profile: minimal + toolchain: stable + override: true - name: Install jaq run: | From 714d60b092bf8ecaeb0d3d6121c82f5e278e8e81 Mon Sep 17 00:00:00 2001 From: Nitsan Avni Date: Tue, 7 Feb 2023 14:14:13 +0000 Subject: [PATCH 3/6] ci: test texttest result --- .github/workflows/jq.yml | 13 +++- jq/texttest-10-day-result | 121 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 jq/texttest-10-day-result diff --git a/.github/workflows/jq.yml b/.github/workflows/jq.yml index 12a99f13..2758eceb 100644 --- a/.github/workflows/jq.yml +++ b/.github/workflows/jq.yml @@ -15,7 +15,8 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + - name: Setup Rust Toolchain + uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable @@ -25,7 +26,13 @@ jobs: run: | cargo install --locked --git https://github.com/01mf02/jaq - - name: Run tests on jq directory + - name: Expect unit test to fail working-directory: jq run: | - ./test-gilded-rose.sh + ! ./test-gilded-rose.sh + + - name: Expect texttest fixture output + working-directory: jq + run: | + jaq --arg days 10 -nr "$(cat gilded-rose.jq) $(cat texttest_fixture.jq)" | + diff - texttest-10-day-result diff --git a/jq/texttest-10-day-result b/jq/texttest-10-day-result new file mode 100644 index 00000000..b0d6247f --- /dev/null +++ b/jq/texttest-10-day-result @@ -0,0 +1,121 @@ +OMGHAI! + +-------- day 0 -------- +name, sellIn, quality ++5 Dexterity Vest, 10, 20 +Aged Brie, 2, 0 +Elixir of the Mongoose, 5, 7 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, 1, 80 +Backstage passes to a TAFKAL80ETC concert, 15, 20 +Backstage passes to a TAFKAL80ETC concert, 10, 49 +Backstage passes to a TAFKAL80ETC concert, 5, 49 +Conjured Mana Cake, 3, 6 + +-------- day 1 -------- +name, sellIn, quality ++5 Dexterity Vest, 9, 19 +Aged Brie, 1, 1 +Elixir of the Mongoose, 4, 6 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, 1, 80 +Backstage passes to a TAFKAL80ETC concert, 14, 21 +Backstage passes to a TAFKAL80ETC concert, 9, 50 +Backstage passes to a TAFKAL80ETC concert, 4, 50 +Conjured Mana Cake, 2, 5 + +-------- day 2 -------- +name, sellIn, quality ++5 Dexterity Vest, 8, 18 +Aged Brie, 0, 2 +Elixir of the Mongoose, 3, 5 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, 1, 80 +Backstage passes to a TAFKAL80ETC concert, 13, 22 +Backstage passes to a TAFKAL80ETC concert, 8, 50 +Backstage passes to a TAFKAL80ETC concert, 3, 50 +Conjured Mana Cake, 1, 4 + +-------- day 3 -------- +name, sellIn, quality ++5 Dexterity Vest, 7, 17 +Aged Brie, -1, 4 +Elixir of the Mongoose, 2, 4 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, 1, 80 +Backstage passes to a TAFKAL80ETC concert, 12, 23 +Backstage passes to a TAFKAL80ETC concert, 7, 50 +Backstage passes to a TAFKAL80ETC concert, 2, 50 +Conjured Mana Cake, 0, 3 + +-------- day 4 -------- +name, sellIn, quality ++5 Dexterity Vest, 6, 16 +Aged Brie, -2, 6 +Elixir of the Mongoose, 1, 3 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, 1, 80 +Backstage passes to a TAFKAL80ETC concert, 11, 24 +Backstage passes to a TAFKAL80ETC concert, 6, 50 +Backstage passes to a TAFKAL80ETC concert, 1, 50 +Conjured Mana Cake, -1, 1 + +-------- day 5 -------- +name, sellIn, quality ++5 Dexterity Vest, 5, 15 +Aged Brie, -3, 8 +Elixir of the Mongoose, 0, 2 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, 1, 80 +Backstage passes to a TAFKAL80ETC concert, 10, 25 +Backstage passes to a TAFKAL80ETC concert, 5, 50 +Backstage passes to a TAFKAL80ETC concert, 0, 50 +Conjured Mana Cake, -2, 0 + +-------- day 6 -------- +name, sellIn, quality ++5 Dexterity Vest, 4, 14 +Aged Brie, -4, 10 +Elixir of the Mongoose, -1, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, 1, 80 +Backstage passes to a TAFKAL80ETC concert, 9, 27 +Backstage passes to a TAFKAL80ETC concert, 4, 50 +Backstage passes to a TAFKAL80ETC concert, -1, 0 +Conjured Mana Cake, -3, 0 + +-------- day 7 -------- +name, sellIn, quality ++5 Dexterity Vest, 3, 13 +Aged Brie, -5, 12 +Elixir of the Mongoose, -2, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, 1, 80 +Backstage passes to a TAFKAL80ETC concert, 8, 29 +Backstage passes to a TAFKAL80ETC concert, 3, 50 +Backstage passes to a TAFKAL80ETC concert, -2, 0 +Conjured Mana Cake, -4, 0 + +-------- day 8 -------- +name, sellIn, quality ++5 Dexterity Vest, 2, 12 +Aged Brie, -6, 14 +Elixir of the Mongoose, -3, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, 1, 80 +Backstage passes to a TAFKAL80ETC concert, 7, 31 +Backstage passes to a TAFKAL80ETC concert, 2, 50 +Backstage passes to a TAFKAL80ETC concert, -3, 0 +Conjured Mana Cake, -5, 0 + +-------- day 9 -------- +name, sellIn, quality ++5 Dexterity Vest, 1, 11 +Aged Brie, -7, 16 +Elixir of the Mongoose, -4, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, 1, 80 +Backstage passes to a TAFKAL80ETC concert, 6, 33 +Backstage passes to a TAFKAL80ETC concert, 1, 50 +Backstage passes to a TAFKAL80ETC concert, -4, 0 +Conjured Mana Cake, -6, 0 From 6f17a85b919d3ded84be7410d4e057f34f6d73eb Mon Sep 17 00:00:00 2001 From: Nitsan Avni Date: Tue, 7 Feb 2023 14:21:33 +0000 Subject: [PATCH 4/6] intentionally fail the ci --- .github/workflows/jq.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jq.yml b/.github/workflows/jq.yml index 2758eceb..69af3e48 100644 --- a/.github/workflows/jq.yml +++ b/.github/workflows/jq.yml @@ -22,6 +22,7 @@ jobs: 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 @@ -33,6 +34,7 @@ jobs: - name: Expect texttest fixture output working-directory: jq + # intentionally fail this step to be in the red run: | - jaq --arg days 10 -nr "$(cat gilded-rose.jq) $(cat texttest_fixture.jq)" | + jaq --arg days 9 -nr "$(cat gilded-rose.jq) $(cat texttest_fixture.jq)" | diff - texttest-10-day-result From e7545c322e94d95690bec7b865452272ef89072d Mon Sep 17 00:00:00 2001 From: Nitsan Avni Date: Tue, 7 Feb 2023 14:27:11 +0000 Subject: [PATCH 5/6] back to green, rename job --- .github/workflows/jq.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/jq.yml b/.github/workflows/jq.yml index 69af3e48..77378561 100644 --- a/.github/workflows/jq.yml +++ b/.github/workflows/jq.yml @@ -8,7 +8,7 @@ on: - jq/* jobs: - build: + test-jq-translation: runs-on: ubuntu-latest steps: @@ -32,9 +32,8 @@ jobs: run: | ! ./test-gilded-rose.sh - - name: Expect texttest fixture output + - name: Expect texttest fixture output (aka 'verify') working-directory: jq - # intentionally fail this step to be in the red run: | - jaq --arg days 9 -nr "$(cat gilded-rose.jq) $(cat texttest_fixture.jq)" | + jaq --arg days 10 -nr "$(cat gilded-rose.jq) $(cat texttest_fixture.jq)" | diff - texttest-10-day-result From 8ee93709a5f5d766278a4b2d670fb40f7921590e Mon Sep 17 00:00:00 2001 From: Nitsan Avni Date: Tue, 7 Feb 2023 17:06:14 +0000 Subject: [PATCH 6/6] jq ci: compare to 30 days texttest stdout --- .github/workflows/jq.yml | 4 +- jq/texttest-10-day-result | 121 -------------------------------------- jq/texttest_fixture.jq | 6 +- 3 files changed, 5 insertions(+), 126 deletions(-) delete mode 100644 jq/texttest-10-day-result diff --git a/.github/workflows/jq.yml b/.github/workflows/jq.yml index 77378561..887aa808 100644 --- a/.github/workflows/jq.yml +++ b/.github/workflows/jq.yml @@ -35,5 +35,5 @@ jobs: - name: Expect texttest fixture output (aka 'verify') working-directory: jq run: | - jaq --arg days 10 -nr "$(cat gilded-rose.jq) $(cat texttest_fixture.jq)" | - diff - texttest-10-day-result + jaq --arg days 31 -nr "$(cat gilded-rose.jq) $(cat texttest_fixture.jq)" | + diff - ../texttests/ThirtyDays/stdout.gr diff --git a/jq/texttest-10-day-result b/jq/texttest-10-day-result deleted file mode 100644 index b0d6247f..00000000 --- a/jq/texttest-10-day-result +++ /dev/null @@ -1,121 +0,0 @@ -OMGHAI! - --------- day 0 -------- -name, sellIn, quality -+5 Dexterity Vest, 10, 20 -Aged Brie, 2, 0 -Elixir of the Mongoose, 5, 7 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, 1, 80 -Backstage passes to a TAFKAL80ETC concert, 15, 20 -Backstage passes to a TAFKAL80ETC concert, 10, 49 -Backstage passes to a TAFKAL80ETC concert, 5, 49 -Conjured Mana Cake, 3, 6 - --------- day 1 -------- -name, sellIn, quality -+5 Dexterity Vest, 9, 19 -Aged Brie, 1, 1 -Elixir of the Mongoose, 4, 6 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, 1, 80 -Backstage passes to a TAFKAL80ETC concert, 14, 21 -Backstage passes to a TAFKAL80ETC concert, 9, 50 -Backstage passes to a TAFKAL80ETC concert, 4, 50 -Conjured Mana Cake, 2, 5 - --------- day 2 -------- -name, sellIn, quality -+5 Dexterity Vest, 8, 18 -Aged Brie, 0, 2 -Elixir of the Mongoose, 3, 5 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, 1, 80 -Backstage passes to a TAFKAL80ETC concert, 13, 22 -Backstage passes to a TAFKAL80ETC concert, 8, 50 -Backstage passes to a TAFKAL80ETC concert, 3, 50 -Conjured Mana Cake, 1, 4 - --------- day 3 -------- -name, sellIn, quality -+5 Dexterity Vest, 7, 17 -Aged Brie, -1, 4 -Elixir of the Mongoose, 2, 4 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, 1, 80 -Backstage passes to a TAFKAL80ETC concert, 12, 23 -Backstage passes to a TAFKAL80ETC concert, 7, 50 -Backstage passes to a TAFKAL80ETC concert, 2, 50 -Conjured Mana Cake, 0, 3 - --------- day 4 -------- -name, sellIn, quality -+5 Dexterity Vest, 6, 16 -Aged Brie, -2, 6 -Elixir of the Mongoose, 1, 3 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, 1, 80 -Backstage passes to a TAFKAL80ETC concert, 11, 24 -Backstage passes to a TAFKAL80ETC concert, 6, 50 -Backstage passes to a TAFKAL80ETC concert, 1, 50 -Conjured Mana Cake, -1, 1 - --------- day 5 -------- -name, sellIn, quality -+5 Dexterity Vest, 5, 15 -Aged Brie, -3, 8 -Elixir of the Mongoose, 0, 2 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, 1, 80 -Backstage passes to a TAFKAL80ETC concert, 10, 25 -Backstage passes to a TAFKAL80ETC concert, 5, 50 -Backstage passes to a TAFKAL80ETC concert, 0, 50 -Conjured Mana Cake, -2, 0 - --------- day 6 -------- -name, sellIn, quality -+5 Dexterity Vest, 4, 14 -Aged Brie, -4, 10 -Elixir of the Mongoose, -1, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, 1, 80 -Backstage passes to a TAFKAL80ETC concert, 9, 27 -Backstage passes to a TAFKAL80ETC concert, 4, 50 -Backstage passes to a TAFKAL80ETC concert, -1, 0 -Conjured Mana Cake, -3, 0 - --------- day 7 -------- -name, sellIn, quality -+5 Dexterity Vest, 3, 13 -Aged Brie, -5, 12 -Elixir of the Mongoose, -2, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, 1, 80 -Backstage passes to a TAFKAL80ETC concert, 8, 29 -Backstage passes to a TAFKAL80ETC concert, 3, 50 -Backstage passes to a TAFKAL80ETC concert, -2, 0 -Conjured Mana Cake, -4, 0 - --------- day 8 -------- -name, sellIn, quality -+5 Dexterity Vest, 2, 12 -Aged Brie, -6, 14 -Elixir of the Mongoose, -3, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, 1, 80 -Backstage passes to a TAFKAL80ETC concert, 7, 31 -Backstage passes to a TAFKAL80ETC concert, 2, 50 -Backstage passes to a TAFKAL80ETC concert, -3, 0 -Conjured Mana Cake, -5, 0 - --------- day 9 -------- -name, sellIn, quality -+5 Dexterity Vest, 1, 11 -Aged Brie, -7, 16 -Elixir of the Mongoose, -4, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, 1, 80 -Backstage passes to a TAFKAL80ETC concert, 6, 33 -Backstage passes to a TAFKAL80ETC concert, 1, 50 -Backstage passes to a TAFKAL80ETC concert, -4, 0 -Conjured Mana Cake, -6, 0 diff --git a/jq/texttest_fixture.jq b/jq/texttest_fixture.jq index 477147bb..12c08dc3 100644 --- a/jq/texttest_fixture.jq +++ b/jq/texttest_fixture.jq @@ -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(", ")), + "" ) )