Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add link checker & refactor two files into one #266

Merged
merged 73 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
f2b490b
Add link checker in CI per #250
Aug 4, 2020
be871cd
Fix multiple calls to #250
Aug 4, 2020
d52e732
Fix multiple calls to #250
Aug 4, 2020
f11ea8d
Fix calls with uses and run #250
Aug 4, 2020
9862b5c
cut the problem in half when your trouble shooting ;) #250
Aug 4, 2020
dd9f049
add back in installing muffet #250
Aug 4, 2020
485fcc3
add back in running hugo server #250
Aug 4, 2020
45b5aa2
put it all back in and see if it sticks #250
Aug 4, 2020
ae47243
background the server command so script doesn't stop #250
Aug 4, 2020
2e3bfde
make muffet a very long line instead of multiline #250
Aug 4, 2020
e7f999d
fix call to muffet again #250
Aug 4, 2020
5a78576
fix call to muffet again again #250
Aug 4, 2020
a60af70
add comments and todo #250
Aug 4, 2020
545ba98
muffet back to one line again #250
Aug 4, 2020
c8c12ef
introduce bad image to test muffet #250
Aug 4, 2020
31ec189
revert bad image to test muffet #250
Aug 4, 2020
3ac1365
bump timeout for muffet #250
Aug 4, 2020
114f11a
remove github at large, bring concurency down to 1 to not overwhelm G…
Aug 4, 2020
8af642a
use verbose flags for muffet, test out checking which branch we're on…
Aug 4, 2020
3347bb6
remove debug file #250
Aug 4, 2020
c497c2b
remove debug file #259
Aug 4, 2020
0a5af49
Merge branch '259-add-link-checker-to-ci' of github.com:medic/cht-doc…
Aug 4, 2020
4a971da
pin muffet to 1.3.3, merge ci files w conditional calls to push live …
Aug 4, 2020
c70cf2d
remove typo #259
Aug 4, 2020
6027894
test getting failure() check working, inentionally add broken image #259
Aug 4, 2020
d108cd0
revert inentionally add broken image, exclude GH URLs to test happy p…
Aug 4, 2020
e9e77f9
hopefully working, easy to read, multi-line muffet call #259
Aug 4, 2020
e3982fc
add back in node stuffs so --minify works #259
Aug 4, 2020
0467b67
move node stuffs to master only, add back in broken image, add back i…
Aug 5, 2020
10dd6d8
greatly reduce GH pages being link checked (edit page, open issue, co…
Aug 5, 2020
399ea25
fix GH exclude regex, remove slack test call, fix conditional on buil…
Aug 5, 2020
7f25b65
increase timeout 2x, add GH explicit matches for exclude b/c fancy re…
Aug 5, 2020
2dea4f0
add todo #259
Aug 5, 2020
803658f
add another todo #259
Aug 5, 2020
bd23252
bump concurrency up to 2, fix one gh exclude URL, fingers crossed #259
Aug 6, 2020
876f9d9
fix missing trailing slash omg this should fix it thank you yes pleas…
Aug 6, 2020
24134ff
fix intentional broken img to test happy path #259
Aug 6, 2020
c6b2b14
test restructuring into dependant jobs #259
Aug 6, 2020
2d93047
fix uncommented out line #259
Aug 6, 2020
e01473d
move if from job to step #259
Aug 6, 2020
71052d5
fix a step cannot have both the and keys error #259
Aug 6, 2020
f66b357
refactor jobs more logically #259
Aug 6, 2020
6bed7ae
fix typo #259
Aug 6, 2020
8259c49
test pushifmaster stanzy #259
Aug 6, 2020
424d3d5
merge back into one job, moar #259
Aug 6, 2020
ffdb9c0
you know me, more testing of chaining steps #259
Aug 6, 2020
428807f
trim down all but one todo for master #259
Aug 6, 2020
db2bbec
add todos #259
Aug 6, 2020
1459d2a
hopefully fix if statements #259
Aug 6, 2020
1bca9af
remove debug file #259
Aug 6, 2020
290ebf5
a smidge closer to done now that if statements work - w00t! #259
Aug 6, 2020
da1d696
rename steps to be clear on GH console which goes where #259
Aug 6, 2020
6563dca
attempt to have muffet in it\'s own bash script so it can be run loca…
Aug 6, 2020
cae8a56
debug stuffs #259
Aug 6, 2020
feafce8
debug stuffs x2 #259
Aug 6, 2020
60d0c02
debug stuffs x3 #259
Aug 6, 2020
0475fa8
debug stuffs x4 #259
Aug 6, 2020
104aaf3
debug stuffs x4 #259
Aug 6, 2020
1383393
debug stuffs x7 #259
Aug 7, 2020
de261a9
hopeful fix to path to muffet bash script #259
Aug 7, 2020
4107065
finally, hopefully, accross the finish line, putting everything to po…
Aug 7, 2020
fd87919
remove trailing if #259
Aug 7, 2020
ea326cc
fix typo #259
Aug 7, 2020
72a906a
fix title to more succinct #259
Aug 7, 2020
490e423
update readme with steps to run muffet locally #259
Aug 7, 2020
96d8094
slight wording tweak to muffet run steps #259
Aug 7, 2020
c09e253
fix typos, update language, move build badge to the top, update links…
Aug 7, 2020
8158771
add go to install steps on muffet script #259
Aug 7, 2020
dac03c2
Merge branch 'master' into 259-add-link-checker-to-ci
Aug 7, 2020
f9ed26f
Update subhead in readme per feedback #259
mrjones-plip Aug 10, 2020
f6a5df5
reward link checker flow per feedback #259
mrjones-plip Aug 10, 2020
49447c1
exclude IntelliJ family of IDEs and their .ideo folder #259
mrjones-plip Aug 10, 2020
05a8355
add link fragment to higher up in docs per feedback #259
mrjones-plip Aug 10, 2020
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
30 changes: 30 additions & 0 deletions .github/scripts/muffet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# This script is used in Github Actions to do link checking on commits to branches and master, so
# please edit with care! See ../workflows/ci.yml for specific usage.
#
# If you're doing local development and want to run link checkers locally, please use this script!
# You'll need:
# - install go - https://golang.org/doc/install
# - install muffet - https://github.com/raviqqe/muffet
# - make sure muffet is in your PATH
# - run from root of this repo: ./.github/scripts/muffet.sh
#
# If we have errors from this script being too aggressive (see how large downloads on
# download.docker.com are excluded below) you can add additional sites as needed. Please
# use extremely granular URLs so as not to exclude more than we need to.

muffet http://localhost:1313 \
--buffer-size 50000 \
--timeout 35 \
--concurrency 2 \
--ignore-fragments \
--exclude ".*demo\.app\.medicmobile\.org.*" \
--exclude ".*download\.docker\.com.*" \
--exclude ".*www\.npmjs\.com/org/medic/team/developers" \
--exclude "https://github\.com/medic/cht-docs/issues/new.*" \
--exclude "https://github\.com/medic/cht-core/issues/new.*" \
--exclude "https://github\.com/medic/cht-docs/commit.*" \
--exclude "https://github\.com/medic/cht-core/commit.*" \
--exclude "https://github\.com/medic/cht-docs/edit/master/.*" \
--exclude ".*localhost:5984.*"
33 changes: 0 additions & 33 deletions .github/workflows/build-any.branch.yml

This file was deleted.

78 changes: 54 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,72 @@
name: CHT Documentation Site Build
# Notes:
# - All software installed below is pinned so they don't get upgraded and break w/o us knowing why.
# - If you bump one version up to latest, please bump them all so we stay current!
# - Hugo builds the site twice: once for link checking and once minified for pushing live
# - Bash script for muffet is intentionally stand alone so devs/content editors can easily run it locally

on:
on:
push:
branches:
- master
- '*' # branch checking is below so all this is one CI file

name: Test site and push live if we're on Master
jobs:
build:

BuildLinkCheckPushLive:
name:
runs-on: ubuntu-18.04

steps:
- name: Git checkout

- name: All Branches - Git checkout, including recursive call for Docsy theme
uses: actions/checkout@v2
with:
submodules: recursive # Fetch the Docsy theme
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

- name: Install Node depencies
uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: npm install
- run: npm install -g postcss-cli
- run: npm i -D autoprefixer

- name: Setup hugo
- name: All Branches - Install hugo extended v0.71.1
uses: peaceiris/actions-hugo@v2
with:
hugo-version: "0.71.1"
extended: true

- name: Build
# Pinning to current version as of Aug 3, 2020 for stability
- name: All Branches - Install Go v1.14
uses: actions/setup-go@v2
with:
go-version: '1.14'

# Pinning to current version as of Aug 3, 2020 for stability
- name: All Branches - Install Muffet v1.3.3
run: env GO111MODULE="on" go get github.com/raviqqe/[email protected]

# run in background so CI doesn't hang waiting for "ctrl + c". Sleep so hugo server is ready
- name: All Branches - Serve Hugo site
run: |
hugo server&
sleep 5

- name: All Branches - Run Muffet link checker
shell: bash
run: ./.github/scripts/muffet.sh

- name: Master Branch Only - Install Node 12.x
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/setup-node@v1
with:
node-version: '12.x'

- name: Master Branch Only - Install npm modules for hugo build
if: ${{github.ref == 'refs/heads/master' }}
run: |
npm install
npm install -g postcss-cli
npm i -D autoprefixer

- name: Master Branch Only - Build for prod with minify
if: github.ref == 'refs/heads/master'
run: env HUGO_ENV="production" hugo --minify

- name: Deploy
- name: Master Branch Only - Deploy to GH pages
if: ${{ github.ref == 'refs/heads/master' }}
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.DEPOLY_TO_SITE}}
Expand All @@ -44,16 +76,14 @@ jobs:
user_email: medic-ci@github
publish_branch: master

- name: Failed Deploy
- name: Master Branch Only - Report errors to Slack, if any
if: ${{ github.ref == 'refs/heads/master' && failure() }}
uses: rtCamp/[email protected]
if: ${{ failure() }}
env:
SLACK_WEBHOOK: '${{ secrets.SLACK_WEB_HOOK }}'
SLACK_CHANNEL: '#cht-squad-docs'
SLACK_COLOR: '#3278BD'
SLACK_ICON: ":flappingphone:"
SLACK_MESSAGE: 'Deploy Failed'
SLACK_TITLE: CHT DOCS DEPLOY
SLACK_USERNAME: Medic-Bot


SLACK_TITLE: CHT DOCS DEPLOY
SLACK_USERNAME: Medic-Bot
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Documentation for the Community Health Tookit
# Documentation for the Community Health Toolkit

[![CHT Documentation Site Build](https://github.com/medic/cht-docs/workflows/CHT%20Documentation%20Site%20Build/badge.svg)](https://github.com/medic/cht-docs/actions)

## About

This repo contains documentation for the Community Health Toolkit (CHT), and how to build digital health applications with [CHT Core](https://github.com/medic/cht-core).

The documentation is built using Markdown pages, which can be converted into a navigatable website using a static-site-generator. The Hugo static-site-generator is being used with the Docsy theme. To maintain portability content should be written in plain Markdown with limited use of HTML, custom shortcodes, and modifications to the theme. Contributions should align with the [documentation style guide](https://docs.communityhealthtoolkit.org/contribute/docs/style-guide/).
The documentation is built using Markdown pages, which can be converted into a navigable website using a static-site-generator. The Hugo static-site-generator is being used with the [Docsy theme](https://themes.gohugo.io/docsy/). To maintain portability, content should be written in plain Markdown with limited use of HTML, custom shortcodes, and modifications to the theme. Contributions should align with the [documentation style guide](https://docs.communityhealthtoolkit.org/contribute/docs/style-guide/).

## Installing Hugo

Expand All @@ -16,15 +18,25 @@ To install, follow the [installation instructions for your Operating System](htt

1. Get local copies of the project submodules so you can build and run your site locally:
- `git submodule update --init --recursive`

2. Build your site:
1. Build your site:
- `hugo server`
- If there are any errors, check that you have the latest version of Hugo, and are using the extended version.
1. Preview your site in your browser at: http://localhost:1313/
1. As you make changes to the site, your browser will automatically reload your local dev site so you can easily and quickly see your changes.

3. Preview your site in your browser at: http://localhost:1313/
## Optional Link Checking
mrjones-plip marked this conversation as resolved.
Show resolved Hide resolved

## Continuous Deployment
We validate that all links on the docs site work (do not 404) using a tool called [Muffet](https://github.com/raviqqe/muffet) along with [Actions](https://github.com/features/actions). If you're creating a lot of new links, or editing a lot of existing links, you may optionally run Muffet locally before pushing your commits. This will save a lot of time of pushing a build, waiting for the Action to run, finding you have a broken link, fixing it, pushing a new change etc.
mrjones-plip marked this conversation as resolved.
Show resolved Hide resolved

All changes to `master` branch run a [GitHub action](.github/workflows/ci.yml) to deploy the documentation site: [docs.communityhealthtoolkit.org](https://docs.communityhealthtoolkit.org)
- Install [Go](https://golang.org/doc/install) as a prerequisite
- Install Muffet: `go get -u github.com/raviqqe/muffet`
- Ensure you've run `hugo server` so your local docs instance is reachable at http://localhost:1313/
- Test the links with the [`muffet.sh`](https://github.com/medic/cht-docs/blob/master/.github/scripts/muffet.sh) script. If you're in the root of this repo, that'd be: `./.github/scripts/muffet.sh`

It should take about 60 seconds depending on your Internet connection. If Muffet returns no output, you have no broken links, congrats!

_Note_: The `muffet.sh` script here is the identical script we run on GitHub. If you simply run `muffet http://localhost:1313` you will hit GitHub's rate limiting and get lots of [429's](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429). Our script intentionally reduces concurrency and excludes some repetitive GitHub URLs.

## Continuous Deployment

![CHT Documentation Site Build](https://github.com/medic/cht-docs/workflows/CHT%20Documentation%20Site%20Build/badge.svg)
All changes to `master` branch run a [GitHub action](.github/workflows/ci.yml) to first check for any broken links (per above) and then deploy to the documentation site: [docs.communityhealthtoolkit.org](https://docs.communityhealthtoolkit.org)
mrjones-plip marked this conversation as resolved.
Show resolved Hide resolved