-
Notifications
You must be signed in to change notification settings - Fork 11
Milestone #2: Implement build-tokens CLI Command #34
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
57ae7e9
feat: add Paragon build-tokens command using tutor custom jobs
Ang-m4 c8bf872
docs: update README with usage instructions and troubleshooting
Ang-m4 ef34e5a
refactor: move build_tokens command to dedicated module
Ang-m4 4566ed2
chore: update Node.js version to 22-alpine in Dockerfile
Ang-m4 94d732f
chore(build): add package.json to manage paragon dependencies
Ang-m4 a0d9e00
chore: downgrade Node.js version to 20-alpine in Dockerfile
Ang-m4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
plugins/tutor-contrib-paragon/tutorparagon/patches/local-docker-compose-jobs-services
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Paragon Builder | ||
| paragon-builder-job: | ||
| image: {{ PARAGON_BUILDER_IMAGE }} | ||
| environment: | ||
| - PARAGON_ENABLED_THEMES={{ PARAGON_ENABLED_THEMES | join(',') }} | ||
| volumes: | ||
| - "./../../{{ PARAGON_THEME_SOURCES_PATH }}:/theme-sources" | ||
| - "./../../{{ PARAGON_COMPILED_THEMES_PATH }}:/compiled-themes" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...ins/tutor-contrib-paragon/tutorparagon/templates/paragon/build/paragon-builder/Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| FROM node:18-alpine | ||
Ang-m4 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| COPY entrypoint.sh /entrypoint.sh | ||
|
|
||
| RUN npm install --save @openedx/paragon && \ | ||
Ang-m4 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| chmod +x /entrypoint.sh | ||
|
|
||
| ENTRYPOINT ["sh", "/entrypoint.sh"] | ||
|
|
||
| CMD [] | ||
60 changes: 60 additions & 0 deletions
60
.../tutor-contrib-paragon/tutorparagon/templates/paragon/build/paragon-builder/entrypoint.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #!/bin/sh | ||
| set -e | ||
|
|
||
| SOURCE_DIR="/theme-sources" # Volume mounted by Paragon plugin | ||
| FINAL_BUILD_DIR="/compiled-themes" # Volume mounted by Paragon plugin | ||
| TMP_BUILD_DIR="$(mktemp -d /tmp/paragon-build.XXXXXX)" | ||
|
|
||
|
|
||
| has_themes() { | ||
| # This function checks if the --themes flag is present in the arguments | ||
| # Returns 0 if --themes is found, 1 otherwise | ||
| # Usage: has_themes "$@" | ||
|
|
||
| for arg in "$@"; do | ||
| [ "$arg" = "--themes" ] && return 0 | ||
| done | ||
| return 1 | ||
| } | ||
|
|
||
| parse_args() { | ||
| # This function parses arguments injected by Tutor. | ||
| # Tutor runs jobs via `sh -e -c '…'`, reserving $1–$3 for its wrapper and | ||
| # bundling all user flags into $4. The function then extracts the raw flags | ||
| # string from $4, shifts off the wrapper args, and verifies—or appends—the | ||
| # selected themes definition. | ||
|
|
||
| if [ "$#" -lt 4 ]; then | ||
| echo "Error: Expected at least 4 args, got $#. Must run via tutor." | ||
| exit 1 | ||
| fi | ||
|
|
||
| shift 3 | ||
|
|
||
| if ! has_themes "$@"; then | ||
| if [ -n "${PARAGON_ENABLED_THEMES:-}" ]; then | ||
| echo "Using PARAGON_ENABLED_THEMES: ${PARAGON_ENABLED_THEMES}" | ||
| set -- "$@" --themes "${PARAGON_ENABLED_THEMES}" | ||
| fi | ||
| fi | ||
|
|
||
| printf '%s\n' "$@" | ||
| } | ||
|
|
||
| set -- $(parse_args "$@") | ||
|
|
||
| # Executes the Paragon CLI to build themes. | ||
| # It uses a temporary directory to avoid volume permissions issues | ||
| npx paragon build-tokens \ | ||
| --source "$SOURCE_DIR" \ | ||
| --build-dir "$TMP_BUILD_DIR" \ | ||
| "$@" | ||
|
|
||
| # Moves the built themes to the final volume directory. | ||
| mkdir -p "$FINAL_BUILD_DIR" | ||
| cp -a "$TMP_BUILD_DIR/." "$FINAL_BUILD_DIR/" | ||
|
|
||
| # Clean up | ||
| rm -rf "$TMP_BUILD_DIR" | ||
|
|
||
| exit 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.