Skip to content

Commit ac22504

Browse files
authored
Merge pull request #15 from Arcadia-Science/ek/empty-repo
Merge full codebase review
2 parents 9e103b7 + 5c1b466 commit ac22504

27 files changed

+745
-309
lines changed

.github/workflows/build.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
on:
2+
# Run the workflow when new tags are created.
3+
push:
4+
tags:
5+
- v*
6+
# Allow the workflow to be triggered manually.
7+
workflow_dispatch:
8+
9+
name: Build
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
env:
19+
PUBLISH_BRANCH: publish
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v5
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: 3.12
32+
33+
- name: Create a name for the build branch
34+
run: |
35+
git checkout main
36+
echo "BUILD_BRANCH=build-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
37+
38+
# Reset the `publish` branch to point to `main`, because we use the `publish` branch
39+
# only to store the build artifacts, not for version control.
40+
- name: Reset the publish branch
41+
run: |
42+
git checkout -b $PUBLISH_BRANCH || true
43+
git checkout $PUBLISH_BRANCH
44+
git reset --hard origin/main
45+
git push --force origin $PUBLISH_BRANCH
46+
git checkout main
47+
48+
# Delete the build branch if it already exists,
49+
# as the `peter-evans/create-pull-request` action used below will update the branch
50+
# if it exists, which we don't want.
51+
# Note: deleting the build branch will also close the corresponding PR, if it exists.
52+
- name: Delete the build branch
53+
run: |
54+
git branch -D $BUILD_BRANCH || true
55+
git push --force --delete origin $BUILD_BRANCH || true
56+
57+
- name: Build the publication
58+
run: |
59+
git checkout main
60+
uv run --no-project _build.py
61+
62+
# Open a PR to merge the build artifacts into the `publish` branch.
63+
# Note: this action automatically creates the build branch and commits all unstaged changes to it.
64+
- name: Open PR
65+
uses: peter-evans/create-pull-request@v7
66+
env:
67+
PR_BODY: |
68+
This PR creates a new version of the public Quarto publication. It was automatically created by the `build.yml` workflow.
69+
70+
To preview this version of the publication, check out this PR branch locally and run `quarto preview`.
71+
72+
To publish this version of the publication, merge this PR into the `publish` branch.
73+
with:
74+
# `base` is the target branch for the PR.
75+
base: ${{ env.PUBLISH_BRANCH }}
76+
# `branch` is the source branch for the PR.
77+
branch: ${{ env.BUILD_BRANCH }}
78+
commit-message: "Update the public Quarto publication"
79+
title: "[Publication] Update the public Quarto publication"
80+
body: ${{ env.PR_BODY }}

.github/workflows/publish.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This workflow is derived from an example workflow in the Quarto docs here:
2+
# https://quarto.org/docs/publishing/github-pages.html#github-action.
3+
14
on:
25
workflow_dispatch:
36
push:
@@ -6,13 +9,35 @@ on:
69
name: Quarto Publish
710

811
jobs:
9-
build-deploy:
12+
publish:
1013
runs-on: ubuntu-latest
1114
permissions:
1215
contents: write
1316
steps:
1417
- name: Check out repository
1518
uses: actions/checkout@v4
19+
with:
20+
# Ensure that the `publish` branch is checked out.
21+
ref: publish
22+
23+
# This is needed to create the `gh-pages` branch.
24+
- name: Set up Git user
25+
run: |
26+
git config --global user.name "github-actions[bot]"
27+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
28+
29+
# The `quarto-actions/publish` action does not create the `gh-pages` branch,
30+
# so we need to create it manually here (if it does not exist).
31+
- name: Create the `gh-pages` branch if it does not exist
32+
run: |
33+
git fetch origin
34+
if ! git show-ref --verify --quiet refs/remotes/origin/gh-pages; then
35+
git checkout --orphan gh-pages
36+
git rm -rf --quiet .
37+
git commit --allow-empty -m "Initializing gh-pages branch"
38+
git push origin gh-pages
39+
git checkout publish
40+
fi
1641
1742
- name: Set up Quarto
1843
uses: quarto-dev/quarto-actions/setup@v2

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Claude Code
2+
CLAUDE.md
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,3 @@ execute:
2929
.PHONY: preview
3030
preview:
3131
quarto preview
32-
33-
.PHONY: bump-version
34-
bump-version:
35-
python _bump_version.py

README.md

Lines changed: 19 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,34 @@
1-
# Notebook pub template
1+
# Notebook Publication Template
22

3-
This repo is a template for notebook publications. The publication rendered and hosted by this repository serves as a demo that can be viewed at [this URL](https://arcadia-science.github.io/notebook-pub-template/).
3+
This repo is a template for Jupyter notebook publications. The template produces a publication rendered and hosted by Quarto, which can be viewed at [this demo URL](https://arcadia-science.github.io/notebook-pub-template/).
44

5-
## How to use this template
5+
## Template Documentation
66

7-
1. Create a repo from this template
7+
All the learning resources for this template can be found in `developer-docs/`.
88

9-
In the top-right of this GitHub repo, select the green button that says "*Use this template*".
9+
- [Quickstart Guide](developer-docs/QUICKSTART.md) - **The most efficient way to get started** is to follow this guide (the rest can wait)
10+
- [Environment Setup Guide](developer-docs/ENVIRONMENT_SETUP.md) - How to set up your development environment
11+
- [Publishing Guide](developer-docs/PUBLISHING_GUIDE.md) - How to publish your notebook publication
12+
- [Template Architecture](developer-docs/TEMPLATE_ARCHITECTURE.md) - Understanding the template's structure
1013

11-
**IMPORTANT**: When creating your repo from this template, you need to **check the box** that says, "*Include all branches*". This is because the hosted pub is managed on a separate branch.
14+
---
1215

13-
1. Config edits
16+
**NOTE: When ready to publish, fill in the information below, then delete this line and everything above it.**
1417

15-
* Replace the variables in `_variables.yml`
16-
- For `google_analytics`, provide the publishing team your repo name and they'll provide you a Google Analytics tracking ID.
17-
* Replace the variables in `authors.yml`.
18-
- This can always be updated, but for now at least add yourself.
18+
# [PUB-TITLE]
1919

20-
1. Install Quarto
20+
This code repository contains or points to all materials required for creating and hosting the publication entitled, *"[PUB-TITLE]"*.
2121

22-
The publication is rendered with [Quarto](https://quarto.org/). If you don’t have it installed (check with quarto --version), you can install it [here](https://quarto.org/docs/get-started/).
22+
The publication is hosted at [this URL]([PUB-URL]).
2323

24-
1. Setup the code environment
24+
## Data Description
2525

26-
This repository uses conda to manage the computational and build environment. If you don’t have it installed (check with `conda --version`), you can find operating system-specific instructions for installing miniconda [here](https://docs.anaconda.com/miniconda/).
26+
[DESCRIPTION OF THE DATA]
2727

28-
When you're ready, run the following commands to create and activate the environment. Replace `[REPO-NAME]` with your repository name.
28+
## Reproduce
2929

30-
```bash
31-
conda env create -n [REPO-NAME] --file env.yml
32-
conda activate [REPO-NAME]
33-
```
30+
Please see [SETUP.qmd](SETUP.qmd).
3431

35-
(As you introduce dependencies to your publication, or if you already have your full set of dependencies, add them to `env.yml` with the version pinned.)
32+
## Contribute
3633

37-
Now, install any internal packages in the repository:
38-
39-
```bash
40-
pip install -e .
41-
```
42-
43-
And finally, install the [pre-commit](https://pre-commit.com/) hooks:
44-
45-
```bash
46-
pre-commit install
47-
```
48-
49-
Test your installation with `make preview`. Your pub will open up in your browser.
50-
51-
Afterwards, create a branch to work on (don't commit to `main` directly).
52-
53-
1. Register your publication with the Pub Team
54-
55-
If you intend to publish your analysis, fill out the "*Kick off a new pub*" form on the AirTable [Publishing toolkit](https://www.notion.so/arcadiascience/Publishing-2-0-f0c51bf29d1d4356a86e6cf8a72ae88b?pvs=4#e1de83e8dd2a4081904064347779ed25).
56-
57-
1. Create your pub
58-
59-
Edit `index.ipynb` to create your pub. As you work, render it in a live preview with `make preview`.
60-
61-
62-
## How to publish
63-
64-
1. Enable read/write permissions for GitHub Actions
65-
66-
In your repo, go to *Settings* -> *Actions* -> *General* -> *Workflow permissions*, and check the box, "*Read and write permissions*"
67-
68-
1. Populate the `README_TEMPLATE.md`
69-
70-
Populate `README_TEMPLATE.md` and then rename it to `README.md`.
71-
72-
**NOTE**: The content you're reading now is the current `README.md`, which is to be replaced with `README_TEMPLATE.md`.
73-
74-
1. Remove placeholder package
75-
76-
If you did not populate `src/analysis` with your own content, remove it (`rm -rf src/analysis`).
77-
78-
1. Remove reference to the syntax demo from `_quarto.yml`
79-
80-
Feel free to keep `demo.ipynb` in your repo, but remove the following lines in `_quarto.yml`:
81-
82-
```
83-
- text: 'Demo'
84-
href: demo.ipynb
85-
```
86-
87-
This will remove *Demo* from the navigation bar.
88-
89-
1. Make the repository public
90-
91-
In order for this pub to be open and reproducible, make the [repo public](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/setting-repository-visibility).
92-
93-
1. Enable comments
94-
95-
Comments are handled with [Giscus](https://giscus.app/), which Quarto has an integration for. Once enabled, a widget is placed at the bottom of the publication that provides an interface to read, write, react, and respond to [GitHub Discussions](https://docs.github.com/en/discussions) comments. Comments made through the interface are automatically added as comments to a GitHub Discussions thread of your repository.
96-
97-
First, [enable GitHub Discussions](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/enabling-or-disabling-github-discussions-for-a-repository) for your repo.
98-
99-
Second, [install the Giscus App](https://github.com/apps/giscus) for your repository. Click *Configure*, select *Arcadia-Science*, then select your repository from the dropdown. Click *Update access*.
100-
101-
**IMPORTANT**: Do not deselect any of the other Arcadia-Science repositories that already have the Giscus app installed, *e.g.* `Arcadia-Science/notebook-pub-template`.
102-
103-
Now, edit the comments section in `_quarto.yml` with your repo name:
104-
105-
```yaml
106-
comments:
107-
giscus:
108-
repo: Arcadia-Science/notebook-pub-template
109-
input-position: top
110-
```
111-
112-
You may have to wait a few minutes for `make preview` to properly render the Giscus widget.
113-
114-
1. Get approval from the Pub Team
115-
116-
Like all other pubs, follow the [AirTable toolkit guide](https://airtable.com/appN7KQ55bT6HHfog/pagm69ti1kZK1GhBx) through to the final step, "*Submit your pub for release*".
117-
118-
1. Final run-through
119-
120-
Begin with a clean branch (no uncommitted changes). Then run the notebook from the command line:
121-
122-
```bash
123-
make execute
124-
```
125-
126-
This command will update `index.ipynb` with the latest execution results. Importantly, it may generate runtime artifacts in the `_freeze/` directory.
127-
128-
Then run `make preview` to see how the publication is rendering. Verify that your changes appear how you intend them to appear. If not, make the necessary changes and re-run `make execute`.
129-
130-
Once happy, commit `index.ipynb` and all files in the `_freeze/` directory.
131-
132-
Now, create a pull request to merge your branch into `main`. Once your PR is approved, merge into `main`.
133-
134-
1. Host the publication
135-
136-
Publishing is automated through a GitHub Action that triggers when a pull request is merged into the `publish` branch. Thus, all that's required for your publication to go live is to merge into `publish`. By convention, we only merge changes from the `main` branch into `publish`. This ensures collaborators can merge their completed work into `main`, where others can see and build upon it, while keeping those changes private until they are deliberately hosted by merging `main` into `publish`.
137-
138-
When all your changes have been merged into `main` and you're ready for your publication to go live, open a pull request to merge `main` into `publish`. Once approved and merged, your publication will be live within minutes.
139-
140-
## Publishing revisions
141-
142-
See [CONTRIBUTING.qmd](CONTRIBUTING.qmd).
34+
Please see [CONTRIBUTING.qmd](CONTRIBUTING.qmd).

README_TEMPLATE.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)