Bug 37490 - Add test to detect when yarn.lock is not updated
Summary: Add test to detect when yarn.lock is not updated
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Mason James
QA Contact: Martin Renvoize
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-26 10:40 UTC by Mason James
Modified: 2024-09-05 09:30 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 37490: add a test to detect when yarn.lock is not updated (2.48 KB, patch)
2024-07-26 11:32 UTC, Mason James
Details | Diff | Splinter Review
Bug 37490: add a test to detect when yarn.lock is not updated (2.56 KB, patch)
2024-07-26 13:10 UTC, Matt Blenkinsop
Details | Diff | Splinter Review
Bug 37490: Add a test to detect when yarn.lock is not updated (2.90 KB, patch)
2024-08-02 01:26 UTC, Mason James
Details | Diff | Splinter Review
Bug 37490: Add a test to detect when yarn.lock is not updated (3.03 KB, patch)
2024-08-21 08:56 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Mason James 2024-07-26 10:40:45 UTC
details to come...
Comment 1 Mason James 2024-07-26 11:32:51 UTC
Created attachment 169693 [details] [review]
Bug 37490: add a test to detect when yarn.lock is not updated

to test...

1/ set koha repo to state where yarn.lock is not updated

    $ git reset --hard 67db70d4

2/ run test, observe FAIL

    $ prove ./xt/verify-yarnlock.t
    ./xt/verify-yarnlock.t .. error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
    ./xt/verify-yarnlock.t .. 1/1
    #   Failed test 'verify yarn.lock file is updated correctly'
    ...
    Result: FAIL

3/ set koha repo to state where yarn.lock is updated

    $ yarn install

4/ note yarn.lock is now updated

    $ git status
    ...
    modified:   yarn.lock

5/ run test, observe SUCCESS

    $ prove -v ./xt/verify-yarnlock.t
    ./xt/verify-yarnlock.t ..
    ok 1 - verify yarn.lock file is updated correctly
    All tests successful.
    Files=1, Tests=1,  1 wallclock secs ( 0.02 usr  0.01 sys +  1.16 cusr  0.27 csys =  1.46 CPU)
    Result: PASS
Comment 2 Matt Blenkinsop 2024-07-26 13:10:31 UTC
Created attachment 169698 [details] [review]
Bug 37490: add a test to detect when yarn.lock is not updated

to test...

1/ set koha repo to state where yarn.lock is not updated

    $ git reset --hard 67db70d4

2/ run test, observe FAIL

    $ prove ./xt/verify-yarnlock.t
    ./xt/verify-yarnlock.t .. error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
    ./xt/verify-yarnlock.t .. 1/1
    #   Failed test 'verify yarn.lock file is updated correctly'
    ...
    Result: FAIL

3/ set koha repo to state where yarn.lock is updated

    $ yarn install

4/ note yarn.lock is now updated

    $ git status
    ...
    modified:   yarn.lock

5/ run test, observe SUCCESS

    $ prove -v ./xt/verify-yarnlock.t
    ./xt/verify-yarnlock.t ..
    ok 1 - verify yarn.lock file is updated correctly
    All tests successful.
    Files=1, Tests=1,  1 wallclock secs ( 0.02 usr  0.01 sys +  1.16 cusr  0.27 csys =  1.46 CPU)
    Result: PASS

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Comment 3 Mason James 2024-08-02 01:26:13 UTC
Created attachment 169967 [details] [review]
Bug 37490: Add a test to detect when yarn.lock is not updated

to test...

1/ set koha repo to state where yarn.lock is not updated

    $ git reset --hard 67db70d4

2/ run test, observe FAIL

    $ prove ./xt/verify-yarnlock.t
    ./xt/verify-yarnlock.t .. error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
    ./xt/verify-yarnlock.t .. 1/1
    #   Failed test 'verify yarn.lock file is updated correctly'
    ...
    Result: FAIL

3/ set koha repo to state where yarn.lock is updated

    $ yarn install

4/ note yarn.lock is now updated

    $ git status
    ...
    modified:   yarn.lock

5/ run test, observe SUCCESS

    $ prove -v ./xt/verify-yarnlock.t
    ./xt/verify-yarnlock.t ..
    ok 1 - verify yarn.lock file is updated correctly
    All tests successful.
    Files=1, Tests=1,  1 wallclock secs ( 0.02 usr  0.01 sys +  1.16 cusr  0.27 csys =  1.46 CPU)
    Result: PASS
Comment 4 Mason James 2024-08-02 01:41:17 UTC
NOTE: i improved the test to handle running inside KTD, 
  and using KTD's existing .cache/yarn and node_modules dirs
Comment 5 Martin Renvoize 2024-08-21 08:56:51 UTC
Created attachment 170540 [details] [review]
Bug 37490: Add a test to detect when yarn.lock is not updated

to test...

1/ set koha repo to state where yarn.lock is not updated

    $ git reset --hard 67db70d4

2/ run test, observe FAIL

    $ prove ./xt/verify-yarnlock.t
    ./xt/verify-yarnlock.t .. error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
    ./xt/verify-yarnlock.t .. 1/1
    #   Failed test 'verify yarn.lock file is updated correctly'
    ...
    Result: FAIL

3/ set koha repo to state where yarn.lock is updated

    $ yarn install

4/ note yarn.lock is now updated

    $ git status
    ...
    modified:   yarn.lock

5/ run test, observe SUCCESS

    $ prove -v ./xt/verify-yarnlock.t
    ./xt/verify-yarnlock.t ..
    ok 1 - verify yarn.lock file is updated correctly
    All tests successful.
    Files=1, Tests=1,  1 wallclock secs ( 0.02 usr  0.01 sys +  1.16 cusr  0.27 csys =  1.46 CPU)
    Result: PASS

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Martin Renvoize 2024-08-21 08:57:13 UTC
Never a bad idea to have more tests and catch these cases.

Passing QA
Comment 7 Katrin Fischer 2024-08-21 17:08:45 UTC
Ok, this test is failing for me on main... HELP?

#   Failed test 'verify yarn.lock file is updated correctly'
#   at /kohadevbox/koha/xt/verify-yarnlock.t line 45.
 #          got: '256'
#     expected: '0'
 # Looks like you failed 1 test of 1.
 /kohadevbox/koha/xt/verify-yarnlock.t .. 
 Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests
Comment 8 Katrin Fischer 2024-08-26 09:44:33 UTC
Also: could someone explain when yarn.lock needs updating and how this is done?
Comment 9 Katrin Fischer 2024-09-02 09:11:51 UTC
(In reply to Katrin Fischer from comment #8)
> Also: could someone explain when yarn.lock needs updating and how this is
> done?

I retried it and it passes now!
Comment 10 Katrin Fischer 2024-09-02 10:21:32 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 11 Jonathan Druart 2024-09-05 09:30:50 UTC
I am wondering if this is working correctly.

kohadev-koha@kohadevbox:koha$ prove xt/verify-yarnlock.t
[skip lot of warnings]
error "eslint-plugin-prettier##prettier@>=3.0.0" doesn't satisfy found match of "prettier@2.7.1"
[skip lot of warnings]
error Found 1 errors.
xt/verify-yarnlock.t .. 1/1 
#   Failed test 'verify yarn.lock file is updated correctly'
#   at xt/verify-yarnlock.t line 45.
#          got: '256'
#     expected: '0'
# Looks like you failed 1 test of 1.
xt/verify-yarnlock.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests 

Test Summary Report
-------------------
xt/verify-yarnlock.t (Wstat: 256 (exited 1) Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
Files=1, Tests=1, 31 wallclock secs ( 0.07 usr  0.08 sys + 26.96 cusr 23.01 csys = 50.12 CPU)
Result: FAIL

I was wondering what could happen and first I've removed my local node_modules (/kohadevbox/koha/node_modules)

Then the tests passed!

You can recreate easily, go on the host and run `yarn install` to generate the node_modes dir, then run the tests.