clean. This isn’t intended to produce a file called clean, but instead to clean up any files that can be re-built by make. Think of it as a way to “undo” all of the build steps. Implement a clean target for the paper.pdf Makefile above. You will have to make the target phony. You may find the git ls-files subcommand useful. A number of other very common make targets are listed here.
Makefile
paper.pdf: paper.tex plot-data.png
pdflatex paper.tex
plot-%.png: %.dat plot.py
./plot.py -i $*.dat -o $@
.PHONY: clean
clean:
rm -f $(shell git ls-files -o --exclude-standard)
.PHONY tells make that clean is a command and not a file, ensuring it will be executed everytime.
git ls-files -o returns files that aren't tracked by git (so files created in the make process).
--exclude-standard excludes files that are ignored by git (like in .gitignore_global).
.git/hooks inside any git repository, you will find (currently inactive) files that are run as scripts when a particular action happens. Write a pre-commit hook that runs make paper.pdf and refuses the commit if the make command fails. This should prevent any commit from having an unbuildable version of the paper.
.git/hooks/pre-commit:
pre-commit
#!/bin/bash
# Run make to build the paper
if ! make paper.pdf; then
echo "Build failed. Commit aborted."
exit 1
fi
chmod +x .git/hooks/pre-commit
shellcheck on any shell files in that repository (here is one way to do it). Check that it works!
Create a github repo like [your-github-username].github.io.
You can modify the page's settings in the Pages option on the side-menu under the settings section.
.github/workflows/shellcheck.yml file and add the following lines:
shellsheck.yml
name: Shellcheck
on: [push, pull_request]
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Run Shellcheck
uses: ludeeus/action-shellcheck@2.0.0
with:
files: "**/*.sh"
proselint or write-good on all the .md files in the repository. Enable it in your repository, and check that it works by filing a pull request with a typo in it.
mkdir -p .github/actions/proselint
.github/actions/proselint:
action.yml
name: Proselint
description: Run Proselint on markdown files
runs:
using: "docker"
image: "Dockerfile"
Dockerfile
FROM python:3.8-slim
RUN pip install proselint
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
entrypoint.sh
#!/bin/bash
set -e
# Run proselint on all .md files
for file in $(find . -name '*.md'); do
echo "Linting $file"
proselint "$file"
done
proselint.yml file in the workflows directory you created in the previous question:
entrypoint.sh
name: Proselint Check
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
proselint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Run Proselint
uses: ./.github/actions/proselint