diff --git a/.github/workflows/check_makefiles.yml b/.github/workflows/check_makefiles.yml new file mode 100644 index 0000000..9ffef3b --- /dev/null +++ b/.github/workflows/check_makefiles.yml @@ -0,0 +1,33 @@ +# This is a basic workflow to help you get started with Actions + +name: Check Makefiles + +# Controls when the workflow will run +on: + pull_request: + types: [opened, reopened, review_requested, ready_for_review] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + # Inputs the workflow accepts. + inputs: + tasks: + description: 'Tasks to check (optional); default is all tasks' + default: '' + required: false + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + check: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + # Runs a single command using the runners shell + - name: Check Makefiles + working-directory: tasks/check_makefiles/code + run: bash check_makefiles.sh ${{ github.event.inputs.tasks }} diff --git a/.github/workflows/check_nontask_makefiles.yml b/.github/workflows/check_nontask_makefiles.yml new file mode 100644 index 0000000..b71efdd --- /dev/null +++ b/.github/workflows/check_nontask_makefiles.yml @@ -0,0 +1,29 @@ +# This is a basic workflow to help you get started with Actions + +name: Check non-task Makefiles + +# Controls when the workflow will run +on: + pull_request: + types: [opened, reopened, review_requested] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + # Inputs the workflow accepts. + inputs: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + check: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + # Runs a single command using the runners shell + - name: Check Makefiles + working-directory: tasks/check_makefiles/code + run: bash check_nontask_makefiles.sh \ No newline at end of file diff --git a/paper/Makefile b/paper/Makefile index 01632a9..b7f0564 100644 --- a/paper/Makefile +++ b/paper/Makefile @@ -1,19 +1,13 @@ ## DEFINITIONS -FOLDERS = input -PAPER_SECTIONS = $(shell grep '\\input' paper.tex | grep -v '%.*\\input' | sed 's/^.*\\input{\(.*\.tex\)}.*/\1/') -#These two lines are commented out because paper.tex lacks content at the moment: -#PAPER_INPUTS_TEX = $(shell grep '\\input{' $(PAPER_SECTIONS) | grep -v '%.*\\input' | sed 's/^.*\\input{\(.*\.tex\)}.*/\1/') -#PAPER_INPUTS_IMG = $(shell grep --no-filename '\\includegraphics' $(PAPER_SECTIONS) | grep -v '%.*\\includegraphics' | sed 's/^.*\\includegraphics\[.*\]{\(.*\)}.*/\1/') +PAPER_SECTIONS = $(shell grep -v '%.*input' paper.tex | grep -o 'sections/[A-Za-z_]*\.tex') +PAPER_INPUTS = $(shell grep --no-filename 'input/' $(PAPER_SECTIONS) paper.tex | grep -v '^%.*\\input' | grep -o 'input/[A-Za-z0-9_\.\-]*\.[a-z]*') ## RECIPES -all: $(FOLDERS) $(PAPER_INPUTS_TEX) $(PAPER_INPUTS_IMG) paper.pdf +all: paper.pdf -$(FOLDERS): - mkdir $@ - -paper.pdf: paper.tex $(PAPER_INPUTS_TEX) $(PAPER_INPUTS_IMG) +paper.pdf: paper.tex $(PAPER_INPUTS) if command -v sbatch > /dev/null ; then module load texlive; fi pdflatex -draftmode paper.tex bibtex paper.aux @@ -21,3 +15,6 @@ paper.pdf: paper.tex $(PAPER_INPUTS_TEX) $(PAPER_INPUTS_IMG) pdflatex paper.tex rm paper.log paper.aux paper.out rm paper.bbl paper.blg + +input/: + mkdir $@ diff --git a/slides/Makefile b/slides/Makefile index 16fcea4..8915af8 100644 --- a/slides/Makefile +++ b/slides/Makefile @@ -1,8 +1,7 @@ #DEFINITIONS -SLIDES_SECTIONS := $(shell grep '\\input{' slides.tex | grep -v '%.*\\input' | sed 's/^.*\\input{\(.*\.tex\).*/\1/') -TEX_INPUTS := $(shell grep '\\input{.*\.tex}' $(slides_sections) | grep -v '%.*\\input' | sed 's/^.*\\input{\(.*\.tex\).*/\1/') -IMG_INPUTS := $(shell grep '\\includegraphics' $(slides_sections) | grep -v '%.*\\includegraphics' | sed 's/^.*\\includegraphics\[.*\]{\([\./a-zA-Z0-9_]*\)}.*/\1/') +slides_sections := $(shell grep '\\input' slides.tex | grep -v '%.*input' | grep -o 'sections/[A-Za-z0-9_\-]*\.tex') +slides_inputs := $(shell grep --no-filename 'input/' $(slides_sections) slides.tex | grep -v '^%' | grep -o 'input/[A-Za-z0-9_\.\-]*\.[a-z]*') all: slides.pdf @@ -12,7 +11,7 @@ clean: input/: mkdir $@ -slides.pdf: slides.tex $(SLIDES_SECTIONS) $(TEX_INPUTS) $(IMG_INPUTS) +slides.pdf: slides.tex $(slides_sections) $(slides_inputs) #module load texlive pdflatex -draftmode $< bibtex slides.aux @@ -23,7 +22,7 @@ slides.pdf: slides.tex $(SLIDES_SECTIONS) $(TEX_INPUTS) $(IMG_INPUTS) rm slides.blg slides.bbl #module unload texlive -slides_notesonly.pdf: slides.tex $(SLIDES_SECTIONS) $(TEX_INPUTS) $(IMG_INPUTS) +slides_notesonly.pdf: slides.tex $(slides_sections) $(slides_inputs) sed 's/notes=hide/notes=only/' slides.tex > slides_notesonly.tex pdflatex slides_notesonly.tex #This will fail due to natbib's bug with notes-only beamer rm slides_notesonly.tex slides_notesonly.log diff --git a/tasks/check_makefiles/ReadMe.md b/tasks/check_makefiles/ReadMe.md new file mode 100644 index 0000000..06bcc27 --- /dev/null +++ b/tasks/check_makefiles/ReadMe.md @@ -0,0 +1,13 @@ +# Check Makefiles + +This task includes bash scripts to verify the makefiles in the repo. +These are used by GitHub Actions. + +## Code +* `check_makefiles.sh`: +This script runs `make -n` for each task listed. +If an error occurs, the script exits with a non-zero exit code. +If no task-list argument is provided, the script check all task folders. +* `check_nontask_makefiles.sh`: +This script runs `make -n` in the paper, slides, and logbook folders. +If an error occurs, the script exits with a non-zero exit code. diff --git a/tasks/check_makefiles/code/check_makefiles.sh b/tasks/check_makefiles/code/check_makefiles.sh new file mode 100644 index 0000000..c3509a0 --- /dev/null +++ b/tasks/check_makefiles/code/check_makefiles.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +# this script runs `make -nC` on the given tasks to check Makefiles +# and assume an error occurs when the output includes "Stop." +# note: if no input is provided, +# then all tasks with a Makefile will be checked. + +TASKS="$@" # read in given tasks + +# if no task was given, run over all tasks with Makefiles +if [ "$TASKS" == "" ] +then + TASKS=$(find ../.. -name 'Makefile' | awk -F '/' '{print $3}') +fi + +# default exit status +status=0 + +# run on the given tasks +for task in $TASKS +do + make_res=$(make -nC ../../$task/code 2>&1 | + grep "Stop." | sed "s|.*code: ||" | sed "s/Makefile:/Line /") + if [ "$make_res" != "" ] + then + status=1 + echo "::error file=tasks/$task/code/Makefile::tasks/$task/code/Makefile $make_res" + fi +done + +exit $status + diff --git a/tasks/check_makefiles/code/check_nontask_makefiles.sh b/tasks/check_makefiles/code/check_nontask_makefiles.sh new file mode 100644 index 0000000..74563c3 --- /dev/null +++ b/tasks/check_makefiles/code/check_nontask_makefiles.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# this script runs `make -nC` in the paper, slides, and logbook folders +# It flags an error when the output includes "Stop."" + +# default exit status +status=0 + +# Run Make in the relevant folders +for folder in paper slides logbook +do + make_res=$(make -nC ../../../$folder 2>&1 | + grep "Stop." | sed "s|.*code: ||" | sed "s/Makefile:/Line /") + if [ "$make_res" != "" ] + then + status=1 + echo "::error file=$folder/Makefile::$folder/Makefile $make_res" + fi +done + +exit $status +