Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},

// Respect the project's designated dependencies, and create codechat config file
"postCreateCommand": "pip install -r requirements.txt && git config core.hooksPath .githooks && touch codechat_config.yaml",
"postCreateCommand": "bash scripts/setup.sh",

// Port forwarding
// ---------------
Expand Down Expand Up @@ -71,18 +71,18 @@
"other": "off"
},
"editor.snippetSuggestions": "top",
"xml.validation.enabled": false,
"xml.validation.enabled": true,
"pretext-tools.schema.versionName": "Custom",
"pretext-tools.schema.customPath": "/workspaces/library/schema/tbil.rng",
"redhat.telemetry.enabled": false,
"CodeChat.CodeChatServer.Command": "CodeChat_Server",
"files.eol": "\n",
"files.associations": {
"*.sage": "python"
}
"files.eol": "\n"
},
"extensions": [
"ms-vscode.live-server",
"oscarlevin.pretext-tools",
"CodeChat.codechat",
"streetsidesoftware.code-spell-checker"
"streetsidesoftware.code-spell-checker",
"lov3.sagemath-enhanced"
]
}
}
Expand Down
117 changes: 75 additions & 42 deletions .github/workflows/pretext-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
build:
runs-on: ubuntu-latest
container: oscarlevin/pretext:full
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)

steps:
- name: Checkout source
Expand All @@ -25,23 +26,15 @@ jobs:
- name: install deps
run: pip install -r requirements.txt

- name: quick build instructor versions
id: quickbuild
if: github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && github.event_name != 'workflow_dispatch'
run: |
pretext build precalculus-web-instructor -q
pretext build calculus-web-instructor -q
pretext build linear-algebra-web-instructor -q

- name: build all deploy targets
if: steps.quickbuild.outcome == 'skipped'
# if: steps.quickbuild.outcome == 'skipped'
run: pretext build --deploys

- name: stage deployment
run: pretext deploy --stage-only

- name: build and stage all banks
if: steps.quickbuild.outcome == 'skipped'
# if: steps.quickbuild.outcome == 'skipped'
run: |
python scripts/build_bank.py precalculus --full
python scripts/build_bank.py calculus --full
Expand All @@ -53,10 +46,76 @@ jobs:
name: deploy
path: output/stage

deploy-cloudflare:
deploy-ghpages:
runs-on: ubuntu-latest
needs: build
if: vars.CLOUDFLARE_PROJECT_NAME != '' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download website artifact
uses: actions/download-artifact@v4
with:
name: deploy
path: deploy
- name: Setup GitHub Pages
id: check
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: deploy
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v4

preview:
runs-on: ubuntu-latest
container: oscarlevin/pretext:full
if: github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
outputs:
markdown: ${{ steps.changes.outputs.markdown }}

steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: install deps
run: pip install -r requirements.txt

- name: Set necessary Git permission
run: git config --global --add safe.directory $(pwd)

- name: build previews of all changed files
id: changes
run: python -m scripts.quickbuild_changes

- name: stage deployment
run: pretext deploy --stage-only

# - name: build and stage all banks
# run: |
# python scripts/build_bank.py precalculus --full
# python scripts/build_bank.py calculus --full
# python scripts/build_bank.py linear-algebra --full

- name: Bundle output/stage as artifact
uses: actions/upload-artifact@v4
with:
name: deploy
path: output/stage

deploy-cloudflare:
runs-on: ubuntu-latest
needs: preview
if: github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
permissions:
contents: read
deployments: write
Expand All @@ -70,8 +129,8 @@ jobs:
path: deploy
- name: Create 404.html
run: echo "404 page not found" >> deploy/404.html
- name: Delete CheckIt builds not supported by CloudFlare
run: find . -name "bank.json" -type f -delete
# - name: Delete CheckIt builds not supported by CloudFlare
# run: find . -name "bank.json" -type f -delete
- name: Publish to Cloudflare
id: cloudflare_publish
uses: cloudflare/pages-action@v1
Expand All @@ -87,37 +146,11 @@ jobs:
if: github.event_name == 'pull_request'
with:
script: |
cf_url = "${{ steps.cloudflare_publish.outputs.url }}"
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## 🚀 Preview available 🚀\n\n${{ steps.cloudflare_publish.outputs.url }}\n\n- [Precalculus](${{ steps.cloudflare_publish.outputs.url }}/preview/precalculus/instructor/frontmatter)\n\n- [Calculus](${{ steps.cloudflare_publish.outputs.url }}/preview/calculus/instructor/frontmatter)\n\n- [Linear Algebra](${{ steps.cloudflare_publish.outputs.url }}/preview/linear-algebra/instructor/frontmatter)'
body: `${{ needs.preview.outputs.markdown }}`
})

deploy-ghpages:
runs-on: ubuntu-latest
needs: build
if: vars.PTX_ENABLE_DEPLOY_GHPAGES == 'yes' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download website artifact
uses: actions/download-artifact@v4
with:
name: deploy
path: deploy
- name: Setup GitHub Pages
id: check
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: deploy
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pretext == 2.6.2
pretext == 2.10.1
pelican == 4.9.1
checkit-dashboard == 0.2.6
133 changes: 133 additions & 0 deletions schema/tbil.rng
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<include href="/root/.ptx/2.10.1/core/schema/pretext-dev.rng">
<define name="Subtitle">
<zeroOrMore>
<element name="subtitle">
<optional>
<attribute name="component" />
</optional>
<ref name="TextLong" />
</element>
</zeroOrMore>
</define>
<define name="Bibinfo">
<element name="bibinfo">
<choice>
<group>
<ref name="Author" />
<zeroOrMore>
<ref name="Author" />
</zeroOrMore>
<zeroOrMore>
<ref name="Editor" />
</zeroOrMore>
</group>
<group>
<ref name="Editor" />
<zeroOrMore>
<ref name="Editor" />
</zeroOrMore>
</group>
</choice>
<zeroOrMore>
<ref name="Credit" />
</zeroOrMore>
<optional>
<ref name="Date" />
</optional>
<zeroOrMore>
<ref name="ColophonCredit" />
</zeroOrMore>
<optional>
<element name="edition">
<text />
</element>
</optional>
<optional>
<ref name="Website" />
</optional>
<optional>
<ref name="Copyright" />
</optional>
</element>
</define>
<define name="Author">
<element name="author">
<optional>
<ref name="XMLBase" />
</optional>
<ref name="PersonName" />
<optional>
<ref name="Department" />
</optional>
<optional>
<ref name="Institution" />
</optional>
<optional>
<ref name="Email" />
</optional>
</element>
</define>
<define name="Website">
<element name="website">
<optional>
<ref name="XMLBase" />
</optional>
<ref name="Url"/>
</element>
</define>
<define name="Paragraph">
<element name="p">
<optional>
<ref name="XMLBase" />
</optional>
<optional>
<ref name="UniqueID" />
</optional>
<optional>
<ref name="LabelID" />
</optional>
<optional>
<ref name="Component" />
</optional>
<ref name="TextParagraph" />
</element>
</define>
</include>
<start combine="choice">
<choice>
<ref name="Paragraph" />
<ref name="Author" />
<ref name="Website" />
<ref name="Copyright" />
</choice>
</start>
<define name="MetaDataTitleOptional" combine="interleave">
<optional>
<attribute name="estimated-time" />
</optional>
</define>
<define name="Copyright">
<element name="copyright">
<optional>
<ref name="XMLBase" />
</optional>
<element name="year">
<ref name="TextShort" />
</element>
<element name="holder">
<text />
</element>
<optional>
<element name="minilicense">
<ref name="TextShort" />
</element>
</optional>
<optional>
<ref name="ShortLicense" />
</optional>
</element>
</define>
</grammar>
8 changes: 7 additions & 1 deletion scripts/preview_outcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from checkit.bank import Bank
from checkit import static

def main(book:str, outcome:str, amount:int = 20):
def build_preview(book:str, outcome:str, amount:int = 20):
# check that this outcome exists
exercise_path = Path("source", book, "exercises")
sage_library_path = Path("source", book, "sage")
Expand Down Expand Up @@ -89,9 +89,15 @@ def main(book:str, outcome:str, amount:int = 20):
# copy assets
shutil.copytree(b.build_path(), os.path.join(docs_path, "assets"), dirs_exist_ok=True)

return sandbox_bank_path


def main(book:str, outcome:str, amount:int = 20):
sandbox_bank_path = build_preview(book, outcome, amount)

subprocess.run(['python', '-m', 'http.server', '-d', str(sandbox_bank_path/'docs')])


if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Preview a CheckIt outcome.')
parser.add_argument('book', choices=['precalculus', 'calculus', 'linear-algebra'])
Expand Down
Loading
Loading