-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check Makefiles using GitHub actions (#3)
This PR introduces GitHub actions.
- Loading branch information
Showing
7 changed files
with
140 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
## 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 | ||
pdflatex -draftmode paper.tex | ||
pdflatex paper.tex | ||
rm paper.log paper.aux paper.out | ||
rm paper.bbl paper.blg | ||
|
||
input/: | ||
mkdir $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|