diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..44621a16 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,81 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + paths: + - .github/workflows/main.yml + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: false + +jobs: + test: + name: Default branch checks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: '3.13' + - name: Install uv + uses: astral-sh/setup-uv@v8.1.0 + with: + version: latest + - name: Install dependencies + run: uv pip install -e ".[dev]" --system + - name: Lint + run: make lint + - name: Run tests + run: make test + + deploy-docs: + name: Build and deploy documentation + needs: test + runs-on: ubuntu-latest + if: github.repository == 'PolicyEngine/microdf' + permissions: + contents: write + steps: + - uses: actions/checkout@v6 + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: '3.13' + - name: Set up Node.js + uses: actions/setup-node@v6 + with: + node-version: '24' + - name: Install uv + uses: astral-sh/setup-uv@v8.1.0 + with: + version: latest + - name: Install Python dependencies + run: uv pip install -e ".[dev]" --system + - name: Install MyST + run: npm install -g mystmd + - name: Build documentation with MyST + working-directory: docs + env: + BASE_URL: /microdf + run: | + myst build --html + touch _build/html/.nojekyll + - name: Check documentation output + run: | + test -s docs/_build/html/index.html + test -f docs/_build/html/.nojekyll + - name: Deploy + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: JamesIves/github-pages-deploy-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-pages + folder: docs/_build/html diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml deleted file mode 100644 index 72d0a756..00000000 --- a/.github/workflows/master.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: CI - -on: - push: - branches: [ master ] - -jobs: - test: - name: Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: '3.13' - - name: Install uv - uses: astral-sh/setup-uv@v8.1.0 - with: - version: "latest" - - name: Install dependencies - run: | - uv pip install -e ".[dev]" --system - - name: Run tests - run: make test - - deploy-docs: - name: Build and deploy documentation - needs: test - runs-on: ubuntu-latest - if: github.repository == 'policyengine/microdf' - - steps: - - uses: actions/checkout@v6 - - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: '3.13' - - name: Install uv - uses: astral-sh/setup-uv@v8.1.0 - with: - version: "latest" - - name: Install dependencies - run: | - uv pip install -e ".[dev,docs]" --system - - name: Build Jupyter Book - shell: bash -l {0} - run: | - jb build docs/. - - name: Check documentation build - run: | - for notebook in $(find docs/_build/jupyter_execute -name "*.ipynb"); do - if grep -q '"output_type": "error"' "$notebook"; then - echo "Error found in $notebook" - cat "$notebook" - exit 1 - fi - done - - name: Deploy - uses: JamesIves/github-pages-deploy-action@v4 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages # The branch the action should deploy to. - FOLDER: docs/_build/html # The folder the action should deploy. diff --git a/changelog.d/default-branch-ci.fixed.md b/changelog.d/default-branch-ci.fixed.md new file mode 100644 index 00000000..efcb49a8 --- /dev/null +++ b/changelog.d/default-branch-ci.fixed.md @@ -0,0 +1 @@ +Restore tests and lint on pushes to main and build the deployed documentation with MyST instead of the retired Jupyter Book command. Include and validate the `.nojekyll` marker so GitHub Pages can publish the prebuilt site.