Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
149 changes: 149 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: CI

# Run this workflow every time a new commit is pushed to the repository
on:
push:
branches:
- master
pull_request:

jobs:
ensure-conventions:
name: Ensure conventions are followed
runs-on: ubuntu-latest

steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v2

- name: Ensure src/lib.rs files exist
run: bash ./_test/ensure-lib-src-rs-exist.sh

- name: Count ignores
run: sh ./_test/count-ignores.sh

- name: Check UUIDs
run: sh ./_test/check-uuids.sh

- name: Verify exercise difficulties
run: ./_test/verify-exercise-difficulties.sh

- name: Check exercises for authors
run: ./_test/check-exercises-for-authors.sh

configlet:
name: Setup configlet
runs-on: ubuntu-latest

steps:
# Checks out master locally so that it is available to the scripts.
- name: Checkout master
uses: actions/checkout@v2
with:
ref: master

# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v2

# Sets TRAVIS_PULL_REQUEST to false if this is not a pull request.
- name: set TRAVIS_PULL_REQUEST
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: echo "TRAVIS_PULL_REQUEST=${PR_NUMBER:-false}" >> $GITHUB_ENV

- name: Fetch configlet
run: ./bin/fetch-configlet

- name: Check configlet format
run: ./_test/check-configlet-fmt.sh
Comment thread
coriolinus marked this conversation as resolved.

- name: Ensure readmes are updated
run: sh ./_test/ensure-readmes-are-updated.sh

- name: Lint configlet
run: ./bin/configlet lint .


compilation:
name: Check compilation
runs-on: ubuntu-latest

strategy:
# Allows running the job multiple times with different configurations
matrix:
rust: ["stable", "beta"]
deny_warnings: ['', '1']

steps:
# Checks out master locally so that it is available to the scripts.
- name: Checkout master
uses: actions/checkout@v2
with:
ref: master

# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v2

- name: Setup toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
default: true

# Sets TRAVIS_PULL_REQUEST to false if this is not a pull request.
- name: set TRAVIS_PULL_REQUEST
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: echo "TRAVIS_PULL_REQUEST=${PR_NUMBER:-false}" >> $GITHUB_ENV

# run scripts as steps
# TODO: the TRAVIS_PULL_REQUEST variable is a holdover from before the
# migration to GitHub Actions. The scripts that use it do so in order to
# run only on changed files.
- name: Check exercises
env:
DENYWARNINGS: ${{ matrix.deny_warnings }}
run: ./_test/check-exercises.sh
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}

- name: Ensure stubs compile
env:
DENYWARNINGS: ${{ matrix.deny_warnings }}
run: sh ./_test/ensure-stubs-compile.sh
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}

- name: Check exercise crate
env:
DENYWARNINGS: ${{ matrix.deny_warnings }}
run: sh ./_test/check-exercise-crate.sh
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}

nightly-compilation:
name: Check exercises on nightly (benchmark enabled)
runs-on: ubuntu-latest
continue-on-error: true # It's okay if the nightly job fails

steps:
# Checks out master locally so that it is available to the scripts.
- name: Checkout master
uses: actions/checkout@v2
with:
ref: master

# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v2

- name: Setup nightly toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
default: true

- name: Check exercises
env:
BENCHMARK: '1'
run: ./_test/check-exercises.sh
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion _test/check-configlet-fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ check_pattern="config.json\|config/maintainers.json"

if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
# Check the changes on the current branch against master branch
git diff --name-only master | grep "$check_pattern"
git diff --name-only remotes/origin/master | grep "$check_pattern"
else
# Check the commits on the master branch made during the week
# This is because Travis cron is set to test the master branch weekly.
Expand Down
4 changes: 2 additions & 2 deletions _test/check-exercise-crate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ EXERCISE_CRATE_PATH="util/exercise"

if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
# Check the changes on the current branch against master branch
git diff --name-only master | grep "$EXERCISE_CRATE_PATH"
git diff --name-only remotes/origin/master | grep "$EXERCISE_CRATE_PATH"
else
# Check the commits on the master branch made during the week
# This is because Travis cron is set to test the master branch weekly.
Expand All @@ -23,7 +23,7 @@ TRACK_ROOT="$(git rev-parse --show-toplevel)"

if !(cd "$TRACK_ROOT/$EXERCISE_CRATE_PATH" && cargo check); then
echo "\nAn error has occurred while building the exercise crate.\nPlease make it compile."

exit 1
else
echo "\nexercise crate has been successfully built."
Expand Down
2 changes: 1 addition & 1 deletion _test/check-exercises.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fi
repo=$(cd "$(dirname "$0")/.." && pwd)

if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
files="$(git diff --diff-filter=d --name-only master | grep "exercises/" | cut -d '/' -f -2 | sort -u | awk -v repo=$repo '{print repo"/"$1}')"
files="$(git diff --diff-filter=d --name-only remotes/origin/master | grep "exercises/" | cut -d '/' -f -2 | sort -u | awk -v repo=$repo '{print repo"/"$1}')"
else
files=$repo/exercises/*
fi
Expand Down
2 changes: 1 addition & 1 deletion _test/ensure-readmes-are-updated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ newline=$'\n '

missing_readmes=""
wrong_readmes=""
for exercise in $(git diff --diff-filter=d --name-only master..$(git rev-parse --abbrev-ref HEAD) | grep exercises/ | cut -d'/' -f2 -s | sort -fu); do
for exercise in $(git diff --diff-filter=d --name-only remotes/origin/master..$(git rev-parse --abbrev-ref HEAD) | grep exercises/ | cut -d'/' -f2 -s | sort -fu); do
echo "Checking readme for $exercise"
readme_path="exercises/${exercise}/README.md"
if [ ! -f $readme_path ]; then
Expand Down
2 changes: 1 addition & 1 deletion _test/ensure-stubs-compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
repo=$(cd "$(dirname "$0")/.." && pwd)

if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
changed_exercises="$(git diff --diff-filter=d --name-only master | grep "exercises/" | cut -d '/' -f -2 | sort -u | awk -v repo=$repo '{print repo"/"$1}')"
changed_exercises="$(git diff --diff-filter=d --name-only remotes/origin/master | grep "exercises/" | cut -d '/' -f -2 | sort -u | awk -v repo=$repo '{print repo"/"$1}')"
else
changed_exercises=$repo/exercises/*
fi
Expand Down