From f17b44988a271035a00340bfb1dfafac7e5ca824 Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Mon, 7 Apr 2025 21:01:16 -0600 Subject: [PATCH 1/4] fix spelling error with install scripts; fix markdown for readme's --- pretext/constants.py | 6 +++--- templates/article/README.md | 20 +++++++++----------- templates/book/README.md | 23 ++++++++++------------- templates/course/README.md | 20 +++++++++----------- templates/demo/README.md | 21 +++++++++------------ templates/devcontainer.json | 5 ++--- templates/installPandoc.sh | 2 +- templates/installPretext.sh | 8 -------- 8 files changed, 43 insertions(+), 62 deletions(-) diff --git a/pretext/constants.py b/pretext/constants.py index e6c1c07c..e3cb47ea 100644 --- a/pretext/constants.py +++ b/pretext/constants.py @@ -229,9 +229,9 @@ "devcontainer.json": Path(".devcontainer/devcontainer.json"), "requirements.txt": Path("requirements.txt"), "pretext-cli.yml": Path(".github", "workflows", "pretext-cli.yml"), - "installPretext.sh": Path(".devcontainer", "instalPretext.sh"), - "installPandoc.sh": Path(".devcontainer", "instalPandoc.sh"), - "installLatex.sh": Path(".devcontainer", "instalLatex.sh"), + "installPretext.sh": Path(".devcontainer", "installPretext.sh"), + "installPandoc.sh": Path(".devcontainer", "installPandoc.sh"), + "installLatex.sh": Path(".devcontainer", "installLatex.sh"), "installSage.sh": Path(".devcontainer", "installSage.sh"), } diff --git a/templates/article/README.md b/templates/article/README.md index 00f279f2..dbf66131 100644 --- a/templates/article/README.md +++ b/templates/article/README.md @@ -36,19 +36,17 @@ The most important thing to remember when authoring in a codespace is that you a We have tried to keep the codespace small (so it starts up quickly and doesn't eat through your monthly storage allotment), so we do not include a full TeXLive distribution. We have tried to include most packages and fonts you are likely to need to generate images using `` elements, and to generate PDF print output. However, if you run into a situation where the LaTeX gives errors about packages missing (like it cannot find a `mypackage.sty` file), here is what you should do. 1. To quickly resolve the issue yourself, open a terminal (``Ctrl+Shift+` ``) and use the TeXLive Package Manager to install the missing package. - 1. If you know that the package is called `mypackage` then enter the following two lines: + a. If you know that the package is called `mypackage` then enter the following two lines: -```bash -tlmgr install mypackage -tlmgr path add -``` - - 2. If you don't know the name of the package, but know it should contain `mypackage.sty`, then you can search using - -```bash -tlmgr search --global --all "mypackage.sty" -``` + ```bash + tlmgr install mypackage + tlmgr path add + ``` + b. If you don't know the name of the package, but know it should contain `mypackage.sty`, then you can search using + ```bash + tlmgr search --global --all "mypackage.sty" + ``` 2. To ensure that you don't have to repeat this step every time you recreate the codespace, add the package name to the list of installs inside the file `.devcontainer/installLatex.sh` which gets run every time a codespace is created. diff --git a/templates/book/README.md b/templates/book/README.md index 06a10333..4ce1d16c 100644 --- a/templates/book/README.md +++ b/templates/book/README.md @@ -37,19 +37,17 @@ The most important thing to remember when authoring in a codespace is that you a We have tried to keep the codespace small (so it starts up quickly and doesn't eat through your monthly storage allotment), so we do not include a full TeXLive distribution. We have tried to include most packages and fonts you are likely to need to generate images using `` elements, and to generate PDF print output. However, if you run into a situation where the LaTeX gives errors about packages missing (like it cannot find a `mypackage.sty` file), here is what you should do. 1. To quickly resolve the issue yourself, open a terminal (``Ctrl+Shift+` ``) and use the TeXLive Package Manager to install the missing package. - 1. If you know that the package is called `mypackage` then enter the following two lines: + a. If you know that the package is called `mypackage` then enter the following two lines: -```bash -tlmgr install mypackage -tlmgr path add -``` - - 2. If you don't know the name of the package, but know it should contain `mypackage.sty`, then you can search using - -```bash -tlmgr search --global --all "mypackage.sty" -``` + ```bash + tlmgr install mypackage + tlmgr path add + ``` + b. If you don't know the name of the package, but know it should contain `mypackage.sty`, then you can search using + ```bash + tlmgr search --global --all "mypackage.sty" + ``` 2. To ensure that you don't have to repeat this step every time you recreate the codespace, add the package name to the list of installs inside the file `.devcontainer/installLatex.sh` which gets run every time a codespace is created. @@ -59,5 +57,4 @@ tlmgr search --global --all "mypackage.sty" By far the largest space-hog in a PreTeXt authoring environment is SageMath, which is only required if you generate images using sageplots. By default, SageMath is not installed in a PreTeXt codespace, but it should be easy to install if you need it. -Just open the command palette (`Ctrl+Shift+P` of `F1`) and search for "PreTeXt: Install SageMath". This will also update the `.devcontainer/devcontainer.json` file so that the next time you create a codespace for this project, it should install automatically. - +Just open the command palette (`Ctrl+Shift+P` of `F1`) and search for "PreTeXt: Install SageMath". This will also update the `.devcontainer/devcontainer.json` file so that the next time you create a codespace for this project, it should install automatically. \ No newline at end of file diff --git a/templates/course/README.md b/templates/course/README.md index 2a6b31e1..e0d49fbd 100644 --- a/templates/course/README.md +++ b/templates/course/README.md @@ -62,19 +62,17 @@ The most important thing to remember when authoring in a codespace is that you a We have tried to keep the codespace small (so it starts up quickly and doesn't eat through your monthly storage allotment), so we do not include a full TeXLive distribution. We have tried to include most packages and fonts you are likely to need to generate images using `` elements, and to generate PDF print output. However, if you run into a situation where the LaTeX gives errors about packages missing (like it cannot find a `mypackage.sty` file), here is what you should do. 1. To quickly resolve the issue yourself, open a terminal (``Ctrl+Shift+` ``) and use the TeXLive Package Manager to install the missing package. - 1. If you know that the package is called `mypackage` then enter the following two lines: + a. If you know that the package is called `mypackage` then enter the following two lines: -```bash -tlmgr install mypackage -tlmgr path add -``` - - 2. If you don't know the name of the package, but know it should contain `mypackage.sty`, then you can search using - -```bash -tlmgr search --global --all "mypackage.sty" -``` + ```bash + tlmgr install mypackage + tlmgr path add + ``` + b. If you don't know the name of the package, but know it should contain `mypackage.sty`, then you can search using + ```bash + tlmgr search --global --all "mypackage.sty" + ``` 2. To ensure that you don't have to repeat this step every time you recreate the codespace, add the package name to the list of installs inside the file `.devcontainer/installLatex.sh` which gets run every time a codespace is created. diff --git a/templates/demo/README.md b/templates/demo/README.md index fc096a9e..7ea1f0be 100644 --- a/templates/demo/README.md +++ b/templates/demo/README.md @@ -37,19 +37,17 @@ The most important thing to remember when authoring in a codespace is that you a We have tried to keep the codespace small (so it starts up quickly and doesn't eat through your monthly storage allotment), so we do not include a full TeXLive distribution. We have tried to include most packages and fonts you are likely to need to generate images using `` elements, and to generate PDF print output. However, if you run into a situation where the LaTeX gives errors about packages missing (like it cannot find a `mypackage.sty` file), here is what you should do. 1. To quickly resolve the issue yourself, open a terminal (``Ctrl+Shift+` ``) and use the TeXLive Package Manager to install the missing package. - 1. If you know that the package is called `mypackage` then enter the following two lines: + a. If you know that the package is called `mypackage` then enter the following two lines: -```bash -tlmgr install mypackage -tlmgr path add -``` - - 2. If you don't know the name of the package, but know it should contain `mypackage.sty`, then you can search using - -```bash -tlmgr search --global --all "mypackage.sty" -``` + ```bash + tlmgr install mypackage + tlmgr path add + ``` + b. If you don't know the name of the package, but know it should contain `mypackage.sty`, then you can search using + ```bash + tlmgr search --global --all "mypackage.sty" + ``` 2. To ensure that you don't have to repeat this step every time you recreate the codespace, add the package name to the list of installs inside the file `.devcontainer/installLatex.sh` which gets run every time a codespace is created. @@ -60,4 +58,3 @@ tlmgr search --global --all "mypackage.sty" By far the largest space-hog in a PreTeXt authoring environment is SageMath, which is only required if you generate images using sageplots. By default, SageMath is not installed in a PreTeXt codespace, but it should be easy to install if you need it. Just open the command palette (`Ctrl+Shift+P` of `F1`) and search for "PreTeXt: Install SageMath". This will also update the `.devcontainer/devcontainer.json` file so that the next time you create a codespace for this project, it should install automatically. - diff --git a/templates/devcontainer.json b/templates/devcontainer.json index 084b66ea..0aaa72f4 100644 --- a/templates/devcontainer.json +++ b/templates/devcontainer.json @@ -18,11 +18,10 @@ // Comment or uncomment lines below if you don't or do need that feature. "postCreateCommand": { - "install pretext": "bash ./.devcontainer/installPretext.sh", + // "install sagemath": "bash ./.devcontainer/installSage.sh", "install pandoc": "bash ./.devcontainer/installPandoc.sh", "install latex": "bash ./.devcontainer/installLatex.sh", - // "install sagemath": "bash ./.devcontainer/installSage.sh", - "working": "echo 'installing additional software into codespace.'" + "install pretext": "bash ./.devcontainer/installPretext.sh" }, diff --git a/templates/installPandoc.sh b/templates/installPandoc.sh index b9f83aba..063e4300 100644 --- a/templates/installPandoc.sh +++ b/templates/installPandoc.sh @@ -5,7 +5,7 @@ wget https://github.com/jgm/pandoc/releases/download/3.6.4/pandoc-3.6.4-1-amd64.deb -O pandoc.deb -# wait for 30 second and then double check that no other script is using apt-get: +# wait for 60 second and then double check that no other script is using apt-get: sleep 60 while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do echo "Waiting for apt-get to be free..." diff --git a/templates/installPretext.sh b/templates/installPretext.sh index 3bc137b6..a3700490 100644 --- a/templates/installPretext.sh +++ b/templates/installPretext.sh @@ -3,10 +3,6 @@ # This file was automatically generated with PreTeXt 2.16.1. # If you modify this file, PreTeXt will no longer automatically update it. -while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do - echo "Waiting for apt-get to be free..." - sleep 15 -done sudo apt-get update sudo apt-get install -y --no-install-recommends \ python3-louis \ @@ -19,10 +15,6 @@ pip install pretext[homepage,prefigure] --only-binary {greenlet} --break-system pip install codechat-server --break-system-packages -while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do - echo "Waiting for apt-get to be free..." - sleep 15 -done playwright install-deps playwright install From 060ae954b8ff998204a442bd180425ad88281e87 Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Tue, 8 Apr 2025 07:32:34 -0600 Subject: [PATCH 2/4] add deploy action that uses `pretext deploy`. --- pretext/constants.py | 2 ++ templates/deploy.yml | 64 +++++++++++++++++++++++++++++++++++++++ templates/pretext-cli.yml | 12 ++++++-- 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 templates/deploy.yml diff --git a/pretext/constants.py b/pretext/constants.py index e3cb47ea..c7fc1f9f 100644 --- a/pretext/constants.py +++ b/pretext/constants.py @@ -229,6 +229,7 @@ "devcontainer.json": Path(".devcontainer/devcontainer.json"), "requirements.txt": Path("requirements.txt"), "pretext-cli.yml": Path(".github", "workflows", "pretext-cli.yml"), + "deploy.yml": Path(".github", "workflows", "deploy.yml"), "installPretext.sh": Path(".devcontainer", "installPretext.sh"), "installPandoc.sh": Path(".devcontainer", "installPandoc.sh"), "installLatex.sh": Path(".devcontainer", "installLatex.sh"), @@ -244,6 +245,7 @@ GIT_RESOURCES = [ ".gitignore", "pretext-cli.yml", + "deploy.yml", "devcontainer.json", "installPretext.sh", "installPandoc.sh", diff --git a/templates/deploy.yml b/templates/deploy.yml new file mode 100644 index 00000000..717f4980 --- /dev/null +++ b/templates/deploy.yml @@ -0,0 +1,64 @@ +# This file was automatically generated with PreTeXt 2.16.1. +# If you modify this file, PreTeXt will no longer automatically update it. +# + +name: Build and Deploy +on: + # Currently, this workflow only runs when manually selected (the `workflow_dispatch` event). + # If you would like it to run on other events, uncomment some of the lines below. + + # # Runs on pull requests + # pull_request: + # branches: ["*"] + + # # Runs on pushes to main + # push: + # branches: ["main"] + + # # Runs every day at 00:00 UTC + # schedule: + # - cron: '0 0 * * *' + + # Runs on demand + workflow_dispatch: + +permissions: + contents: write + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + container: oscarlevin/pretext:small + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: add gh-cli + run: | + apt-get update + apt-get install gh jq -y + + - name: setup git config + run: | + git config --global --add safe.directory $(pwd) + git config user.name "${{ github.actor }} via GitHub Actions" + git config user.email "${{ github.actor }}@github_actions.no_reply" + + - name: install deps + run: pip install -r requirements.txt --break-system-packages + + - name: install local ptx files + run: pretext --version + + - name: build deploy targets + run: pretext build --deploys + + - name: run deploy + run: pretext deploy --no-push + + - name: push gh-pages branch + run: git push origin gh-pages --force + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + \ No newline at end of file diff --git a/templates/pretext-cli.yml b/templates/pretext-cli.yml index a73a4d01..88348c6b 100644 --- a/templates/pretext-cli.yml +++ b/templates/pretext-cli.yml @@ -1,14 +1,20 @@ # This file was automatically generated with PreTeXt 2.16.1. # If you modify this file, PreTeXt will no longer automatically update it. # +# This workflow file can be used to automatically build a project and create +# an artifact for deployment. It can also be used to deploy the project to +# GitHub Pages or Cloudflare Pages. +# +# The workflow is triggered on pull requests or can be run manually. You can uncomment +# the `push` event to have it run on pushes to the main branch as well. name: PreTeXt-CLI Actions on: # Runs on pull requests pull_request: branches: ["*"] - # Runs on pushes to main - push: - branches: ["main"] + ## Runs on pushes to main + #push: + # branches: ["main"] # Runs on demand workflow_dispatch: From 6d09d422b0de11b67bd2038b6bd1e65942485388 Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Tue, 8 Apr 2025 07:38:03 -0600 Subject: [PATCH 3/4] update hash --- pretext/resources/resource_hash_table.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pretext/resources/resource_hash_table.json b/pretext/resources/resource_hash_table.json index 64caac4f..01bbd2bc 100644 --- a/pretext/resources/resource_hash_table.json +++ b/pretext/resources/resource_hash_table.json @@ -109,10 +109,11 @@ "project.ptx": "ac4c1327126f021006b2e043df35287e593c5c89de2f5d7bcc3e653227b46e0e", "codechat_config.yaml": "dd2a54caa22b056fd4442b39c230adb359e61a195fcad921c1733c5beea0f89f", ".gitignore": "7df710ee93f2d5b67d3b90292f195b35c2053915eec3a4265a440585a2c94816", - "devcontainer.json": "21c7b3bde8d88e2bd0956221d0f7b935c021738f6e078d9798831785326ffa4d", - "pretext-cli.yml": "419d0487e446a6ec7d1c9a1f78c431dd7ac8f7e5fe683d772685110d1ca99e14", - "installPretext.sh": "e6d198cad4402d18965fbbd7e40b05c4dc858b4d334536b3c00fc835a971e4e6", - "installPandoc.sh": "1d73faa032b137af74dcb9fad2cbc4f70da3bf09a682f90cc213943d4e60710c", + "devcontainer.json": "4d8a29737ff080e9312bad1646262cdf40f54e7e017298d0f59a1cab7fde6955", + "pretext-cli.yml": "2436f740b3d9aa1b1c64ff5da9a2ef281c12087267225d3c9870ccf0c6d87b16", + "deploy.yml": "2f02ebfe0ae2a54edf8e66561e906567424cec5b5467db7d6dd891b56e23ca7b", + "installPretext.sh": "8b4ffc06b5bfd75b63ea2f06406ba72e88c6a1f70ddd365e3eed3d4099bf3a92", + "installPandoc.sh": "0dfd2cf2455efeff82293ba2b3724bc94e20620ed9f87c4cd3ee967d0dedd076", "installLatex.sh": "89fc36da1ac5bf3c79e70990d760f288b94afb71dac03f0651424efbf55663aa", "installSage.sh": "7f2b791271aaf21a0b6c742e9758d4f131b59216c261902fe43c8461143cb407" } From 344716dfd7d6010030f4c0cca679d4f552e4581b Mon Sep 17 00:00:00 2001 From: Oscar Levin Date: Tue, 8 Apr 2025 07:51:45 -0600 Subject: [PATCH 4/4] rename to avoid conflict with previously depricated file --- pretext/constants.py | 4 ++-- pretext/resources/resource_hash_table.json | 2 +- templates/{deploy.yml => pretext-deploy.yml} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename templates/{deploy.yml => pretext-deploy.yml} (100%) diff --git a/pretext/constants.py b/pretext/constants.py index c7fc1f9f..71c183e8 100644 --- a/pretext/constants.py +++ b/pretext/constants.py @@ -229,7 +229,7 @@ "devcontainer.json": Path(".devcontainer/devcontainer.json"), "requirements.txt": Path("requirements.txt"), "pretext-cli.yml": Path(".github", "workflows", "pretext-cli.yml"), - "deploy.yml": Path(".github", "workflows", "deploy.yml"), + "pretext-deploy.yml": Path(".github", "workflows", "pretext-deploy.yml"), "installPretext.sh": Path(".devcontainer", "installPretext.sh"), "installPandoc.sh": Path(".devcontainer", "installPandoc.sh"), "installLatex.sh": Path(".devcontainer", "installLatex.sh"), @@ -245,7 +245,7 @@ GIT_RESOURCES = [ ".gitignore", "pretext-cli.yml", - "deploy.yml", + "pretext-deploy.yml", "devcontainer.json", "installPretext.sh", "installPandoc.sh", diff --git a/pretext/resources/resource_hash_table.json b/pretext/resources/resource_hash_table.json index 01bbd2bc..cebfdc73 100644 --- a/pretext/resources/resource_hash_table.json +++ b/pretext/resources/resource_hash_table.json @@ -111,7 +111,7 @@ ".gitignore": "7df710ee93f2d5b67d3b90292f195b35c2053915eec3a4265a440585a2c94816", "devcontainer.json": "4d8a29737ff080e9312bad1646262cdf40f54e7e017298d0f59a1cab7fde6955", "pretext-cli.yml": "2436f740b3d9aa1b1c64ff5da9a2ef281c12087267225d3c9870ccf0c6d87b16", - "deploy.yml": "2f02ebfe0ae2a54edf8e66561e906567424cec5b5467db7d6dd891b56e23ca7b", + "pretext-deploy.yml": "2f02ebfe0ae2a54edf8e66561e906567424cec5b5467db7d6dd891b56e23ca7b", "installPretext.sh": "8b4ffc06b5bfd75b63ea2f06406ba72e88c6a1f70ddd365e3eed3d4099bf3a92", "installPandoc.sh": "0dfd2cf2455efeff82293ba2b3724bc94e20620ed9f87c4cd3ee967d0dedd076", "installLatex.sh": "89fc36da1ac5bf3c79e70990d760f288b94afb71dac03f0651424efbf55663aa", diff --git a/templates/deploy.yml b/templates/pretext-deploy.yml similarity index 100% rename from templates/deploy.yml rename to templates/pretext-deploy.yml