Skip to content

Commit

Permalink
Merge pull request #639 from pupil-labs/gh_actions_update
Browse files Browse the repository at this point in the history
GH Update WIP
  • Loading branch information
marc-tonsen authored Nov 28, 2023
2 parents 561ebcd + 13a3394 commit 6003126
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 69 deletions.
130 changes: 63 additions & 67 deletions .github/workflows/PR-checks.yml
Original file line number Diff line number Diff line change
@@ -1,99 +1,95 @@
name: on PR
# This workflow is triggered on pull requests to the repository.
# It runs a job to build the docvs, and check for broken links in the files changed in the PR on the built static pages.
# It runs a job to build the docs, and check for broken links.
# It checks for spelling errors in the files changed in the PR.

on:
pull_request

jobs:
build:
name: 📦 Build & 🌍 Check links
name: 📦 ${{ matrix.component }} build
runs-on: ubuntu-latest
outputs:
html_lychee_exited: ${{ steps.stringify.outputs.lychee_exited }}
html_lychee_file: ${{ steps.stringify.outputs.lychee_file }}
strategy:
fail-fast: false
matrix:
component: [neon, invisible, core, alpha-lab, landing-page]
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: pip install nbconvert==7.0.0 packaging
- name: Convert Jupyter notebooks
run: |
shopt -s globstar
jupyter-nbconvert --to markdown **/*.ipynb --ExtractOutputPreprocessor.enabled=False
shopt -u globstar
shell: bash

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: Install vuepress
run: yarn global add vuepress
- name: Install package.json
run: yarn
- name: Build static site with vuepress
# alias for vuepress build src defined in package.json
run: yarn build
- name: Install dependencies
working-directory: ./${{ matrix.component }}
run: npm install

- name: Get size of files in dist
- name: Copy node_modules
shell: bash
run: |
du -ah src/.vuepress/dist
cp -r ${{ matrix.component }}/node_modules .
ls -la
- name: Make build
working-directory: ./${{ matrix.component }}
run: npm run docs:build

- name: 'Get built html files'
- name: Upload
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.component }}
path: ${{ matrix.component }}/.vitepress/dist

- name: Get built HTML files
id: html-files
run: |
html_files=$(find src/.vuepress/dist -name '*.html')
html_files=$(find ./${{ matrix.component }}/.vitepress/dist -name '*.html')
html_files="${html_files//$'\n'/ }"
html_files="${html_files//$'\r'/ }"
echo $html_files
echo "all_html_files=${html_files}" >> $GITHUB_OUTPUT
- name: 'Check Links'
id: lychee
uses: lycheeverse/[email protected]
echo "all_html_files=${html_files}" >> $GITHUB_ENV
check-links:
name: 🖇️ Check Links on Merged HTML
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Download all dist artifacts
uses: actions/download-artifact@v3
with:
path: docs_merged

- name: Display structure of downloaded files
run: ls -R docs_merged

- name: Check Links
uses: lycheeverse/[email protected]
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: -v -n -a 403,503,429,200 -i -b 'src/.vuepress/dist' --exclude-mail --include-verbatim -- ${{ steps.html-files.outputs.all_html_files }}
output: ./lychee/htmlfiles.md
args: -v -n -a 403,503,429,200 --header "accept=*/*" --remap "https://www.youtube-nocookie.com/embed https://youtu.be" -i -b docs_merged/ --exclude-mail --include-verbatim -- $(find docs_merged -name '*.html')
jobSummary: true

- name: 'Outputs as strings'
id: stringify
run: |
EXIT_CODE_STRING="$( printf '%d' "${{ env.lychee_exit_code }}" )"
echo "lychee_exited=${EXIT_CODE_STRING}" >> $GITHUB_OUTPUT
if [ $EXIT_CODE_STRING -eq 0 ]; then
echo "lychee_file=No broken links found" >> $GITHUB_OUTPUT
exit 0
fi
if [ $EXIT_CODE_STRING -eq 1 ]; then
MD_OUT="$( cat ./lychee/htmlfiles.md )"
MD_OUT="${MD_OUT//'%'/'%25'}"
MD_OUT="${MD_OUT//$'\n'/'%0A'}"
MD_OUT="${MD_OUT//$'\r'/'%0D'}"
echo "text<<EOF" >> $GITHUB_OUTPUT
echo "$MD_OUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "lychee_file=${MD_OUT}" >> $GITHUB_OUTPUT
fi
link_fail:
name: 🚨 Fail if links are broken
output: ./lychee/link_errors.md
fail: true

debug-info:
name: Upload Debugging Info
runs-on: ubuntu-latest
needs: build
if: ${{ needs.build.outputs.html_lychee_exited != 0 }}
steps:
- name: 'Fail if links are broken'
run: |
echo "Some links are broken"
exit 1
- uses: actions/checkout@v3

- name: Write commit SHA to gitcommit.txt
shell: bash
run: echo $GITHUB_SHA > gitcommit.txt

- name: Upload Git Commit Info
uses: actions/upload-artifact@v3
with:
name: gitcommit
path: gitcommit.txt

check_spelling:
name: ✍️ Check spelling
Expand All @@ -106,7 +102,7 @@ jobs:
fetch-depth: 2
- name: 'Check Grammar'
id: cspell
uses: streetsidesoftware/cspell-action@v2
uses: streetsidesoftware/cspell-action@v5
with:
files: |
**/*.{md,html,ipynb}
Expand Down
4 changes: 4 additions & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ file:///**/*.js
# Ignore all .py files
./*.py

# More files
./*.webp
./*.woff2

# Subscribe email, needs right post request to the endpoint
https://mailchimp.us3.list-manage.com/subscribe/post

Expand Down
3 changes: 1 addition & 2 deletions invisible/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vitepress";

import { config as default_config } from "./../../default_config.mts";
import { theme_config as default_theme_config } from "./../../default_config.mts";
import { config as default_config, theme_config as default_theme_config } from "./../../default_config.mts";

let theme_config_additions = {
nav: [
Expand Down

0 comments on commit 6003126

Please sign in to comment.