Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ABL scripts to use CORGI #2235

Merged
merged 28 commits into from
Jul 18, 2024
Merged

Update ABL scripts to use CORGI #2235

merged 28 commits into from
Jul 18, 2024

Conversation

TylerZeroMaster
Copy link
Contributor

part of openstax/ce#2182

This new script effectively performs the same steps as the old transformation script:

  • Fetch ABL from https://corgi.ce.openstax.org/api/abl/
    • Fetches entries intended for REX where code_version <= REACT_APP_ARCHIVE
  • Select the newest version of each book
  • Select versions that are not in config.books.json

REACT_APP_ARCHIVE is read from src/config.archive-url.json

The tests show the input and output formats (the output format is the same as before: { <uuid>: <commit_sha>, ... })

@TylerZeroMaster TylerZeroMaster self-assigned this May 13, 2024
@TylerZeroMaster TylerZeroMaster requested a review from a team as a code owner May 13, 2024 15:36
@TomWoodward TomWoodward temporarily deployed to rex-web-corgi-abl-haozijzau2ic May 13, 2024 15:36 Inactive
- Remove old test data
- Add new test data
- Update snapshots with new script

NOTE: The multi-version test data does not include multiple code versions
because the CORGI endpoint will support a query argument that filters by
code version (returns <= code_version)
Add additional commit for each book in multi-version test

When there is more than one commit for a book, the jq filter should select
the newest commit

In the test data, the newest commit for each book is bbbbbbb. The books in the
snapshot should all use this commit.
@TomWoodward TomWoodward temporarily deployed to rex-web-corgi-abl-haozijzau2ic May 13, 2024 15:59 Inactive
@@ -27,8 +27,10 @@ for input_file in "$my_dir"/*.input.json; do
# Actual test goes here
# -------------------------
json=$(cat "$input_file")
node "$my_dir/../entry.js" transform-approved-books-data --data "$json" > "$output_file"
configured_books="{}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't there be tests that exercise the logic of diffing the books against the existing config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick review! Yes, that completely slipped my mind. I added some additional test data for this. The smaller of the new data sets demonstrates what occurs when new versions are present, the other uses some real data to demonstrate that there are no new entries when all ABL versions are already present.


set -e

data="$1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure it really matters, but this seems like a lot to be putting in the arguments. maybe it could read data from stdin and configured_books from a given file path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good point. I originally used inputs like this to separate fetching from transformation and the errors that could occur in each process. I updated the transformation script to read input from 2 files and do some additional checks on the input.

Use slurp to read input from two files into an array
Use process substitution for fetched ABL data

Remove unnecessary check for `detail` property (should be handled by --fail option to curl)
Read abl data and configured books from each input file
@TomWoodward TomWoodward temporarily deployed to rex-web-corgi-abl-haozijzau2ic May 13, 2024 20:23 Inactive
The data was limited to the first 25 entries for brevity

Regardless, the result is the same: no new entries for 20240226.174525
because all the versions from the ABL are already present in configured books
@TomWoodward TomWoodward temporarily deployed to rex-web-corgi-abl-haozijzau2ic May 13, 2024 20:50 Inactive
@TomWoodward TomWoodward temporarily deployed to rex-web-corgi-abl-haozijzau2ic May 13, 2024 22:58 Inactive
@TomWoodward
Copy link
Member

i think we should wait to merge this until the current batch of updates is done.

@TylerZeroMaster is the new system being used already? are we good to merge this whenever?

@TylerZeroMaster
Copy link
Contributor Author

i think we should wait to merge this until the current batch of updates is done.

@TylerZeroMaster is the new system being used already? are we good to merge this whenever?

@TomWoodward The new system is in production, but it is not being used yet: there is another PR in progress to update Enki/webhosting pipeline to use the new system as well. We can wait to merge that Enki PR alongside this one.

Additionally, if the ABL on Github is updated, the version on CORGI will need to be updated to match. I have a script that will "fast-forward" the CORGI ABL data to match what is present on Github, but I have been running it manually.

Overall, the changes can be merged anytime, but I would appreciate a little bit of warning ahead of time.

@TomWoodward
Copy link
Member

@TylerZeroMaster ok, we will shoot to merge this maybe next week after the current batch of updates is done.

also the "ABL Schema Tests' check is failing with some jq compile error

In version 1.7, `if` defaults to returning `.` in the absence of an `else`

In version 1.6, you must explicitly specify `else .`
@TomWoodward TomWoodward temporarily deployed to rex-web-corgi-abl-haozijzau2ic May 16, 2024 16:29 Inactive
@TylerZeroMaster
Copy link
Contributor Author

@TylerZeroMaster ok, we will shoot to merge this maybe next week after the current batch of updates is done.

also the "ABL Schema Tests' check is failing with some jq compile error

Ahh, I think that was because I was using jq version 1.7 which has some changes that must not be backwards compatible. It has been fixed. Let me know when we are ready to merge this change.

@openstaxalina
Copy link

@TomWoodward will bypass the required JIRA ticket (CE Tech doesn't use JIRA) and merge this.

@TomWoodward TomWoodward merged commit 5af586b into main Jul 18, 2024
7 of 9 checks passed
@TomWoodward TomWoodward deleted the corgi-abl branch July 18, 2024 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants