forked from stanford-cs45/spr23-a5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 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,55 @@ | ||
name: 'Run build and tests' | ||
on: | ||
push: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
actions: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v3 | ||
- name: Run Makefile | ||
run: make | ||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: program | ||
path: program | ||
retention-days: 1 | ||
test_setup: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
test_list: ${{ steps.get_list.outputs.TESTS_JSON }} | ||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v3 | ||
- name: Install jq | ||
run: |- | ||
apt-get update | ||
apt-get install jq | ||
- name: Get list of tests | ||
id: get_list | ||
run: |- | ||
export TESTS_JSON=$(find ./tests -type f -exec test -x {} \; -print | jq -Rsc 'gsub("\\s*$";"") | split("\n") | sort') | ||
echo "TESTS_JSON=$TESTS_JSON" >> $GITHUB_OUTPUT | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: [build, test-setup] | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
test: ${{ fromJSON(jobs.test_setup.outputs.test_list) }} | ||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v3 | ||
- name: Run Makefile | ||
run: make | ||
- name: Run test | ||
run: |- | ||
${{ matrix.test }} "$(pwd)"/program |
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,16 @@ | ||
#!/urs/bin/env bash | ||
|
||
# (The absolute path to the program is provided as the first and only argument.) | ||
PROGRAM=$1 | ||
|
||
echo "We've set up a GitHub Actions Workflow that will run all" | ||
echo "of the shell scripts in this directory as a series of tests." | ||
echo | ||
echo "To fail any test, you should use the exit 1 command;" | ||
echo "To end a test early as a success, you should use the exit 0 command." | ||
|
||
echo "Invoke your program with the \$PROGRAM variable; an example is below" | ||
|
||
|
||
# Test 01: Ensure the program runs without error with no arguments. | ||
$PROGRAM |