Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run CI on Github Actions #1815

Merged
merged 7 commits into from
May 5, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow calculates size diffs for the compiled binary of each supported tock board

name: Benchmarks

# Controls when the action will run. Triggers the workflow on pull request
# events but only for the master branch
on:
pull_request:
branches: master

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
# If you add additional jobs, remember to add them to bors.toml
jobs:
benchmarks:
# 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:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1 # pulls version from rust-toolchain file
with:
components: rustfmt, clippy
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install --user cxxfilt
sudo apt install llvm
- name: size report
run: |
./tools/github_actions_size_changes.sh
77 changes: 77 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# This workflow contains all tock-ci, seperated into jobs

name: tock-ci
env:
TERM: xterm # Makes tput work in actions output

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches-ignore: [ staging.tmp, trying.tmp ] # Run CI for all branches except bors tmp branches
pull_request: # Run CI for PRs on any branch

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
# If you add additional jobs, remember to add them to bors.toml
jobs:
ci-format:
# 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:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1 # pulls version from rust-toolchain file
- uses: actions/setup-node@v1
with:
components: rustfmt, clippy
- name: ci-formatting
run: make ci-formatting
- name: ci-documentation
run: |
npm install -g markdown-toc
make ci-documentation

ci-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1

- name: ci-syntax
run: make ci-syntax
- name: ci-compilation
run: make ci-compilation
- name: ci-debug-support-targets
run: make ci-debug-support-targets

- name: collect-build-artifacts
run: make ci-collect-artifacts
- name: upload-build-artifacts
uses: actions/upload-artifact@v2
with:
name: build-artifacts
path: ci-artifacts

ci-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: ci-cargo-tests
run: make ci-cargo-tests
- name: ci-tools
run: |
sudo apt install libusb-1.0-0-dev
make ci-tools

emulation-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- name: qemu tests
run: make emulation-check
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@ ci-netlify:\
@printf "$$(tput bold)* CI-Netlify: Done! *$$(tput sgr0)\n"
@printf "$$(tput bold)*********************$$(tput sgr0)\n"

.PHONY: ci-cargo-tests
ci-cargo-tests:\
ci-libraries\
ci-archs\
ci-kernel\
ci-chips\

.PHONY: ci-format
ci-format:\
ci-formatting\
ci-documentation\

.PHONY: ci-build
ci-build:\
ci-syntax\
ci-compilation\
ci-debug-support-targets\

.PHONY: ci-tests
ci-tests:\
ci-cargo-tests\
ci-tools\

## Actual Rules (Travis)

Expand Down Expand Up @@ -210,6 +232,7 @@ clean:
@echo "$$(tput bold)Clean top-level Cargo workspace" && cargo clean
@for f in `./tools/list_tools.sh`; do echo "$$(tput bold)Clean tools/$$f"; cargo clean --manifest-path "tools/$$f/Cargo.toml" || exit 1; done
@echo "$$(tput bold)Clean rustdoc" && rm -Rf doc/rustdoc
@echo "$$(tput bold)Clean ci-artifacts" && rm -Rf ./ci-artifacts

.PHONY: fmt format formatall
fmt format formatall:
Expand All @@ -226,3 +249,9 @@ list list-boards list-platforms:
@echo " cd boards/hail"
@echo " make"

.PHONY: ci-collect-artifacts
ci-collect-artifacts:
@test -d ./target || (echo "Target directory not found! Build some boards first to have their artifacts collected"; exit 1)
@mkdir -p ./ci-artifacts
@rm -rf "./ci-artifacts/*"
@for f in $$(find ./target -iname '*.bin' | grep -E "release/.*\.bin"); do mkdir -p "ci-artifacts/$$(dirname $$f)"; cp "$$f" "ci-artifacts/$$f"; done
1 change: 1 addition & 0 deletions bors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# pushed to master.
status = [
"continuous-integration/travis-ci/push",
"ci-format", "ci-build", "ci-tests", "emulation-check"
]

# List of PR labels that may not be attached to a PR when it is r+-ed.
Expand Down
55 changes: 55 additions & 0 deletions tools/github_actions_size_changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash

# Post github check indicating how a PR affects flash and RAM use for different boards.
# This script is run by Github actions after successful PR builds. It reports resource differences between
# the target branch before and after merging in the PR.
# This script only reports updates for boards whose size have changed as a result of the PR being
# tested, and does not currently support analyzing size differences in RISC-V boards.

UPSTREAM_REMOTE_NAME="${UPSTREAM_REMOTE_NAME:-origin}"
GITHUB_BASE_REF="${GITHUB_BASE_REF:-master}"

set -e

# Bench the current commit that was pushed. Requires navigating back to build directory
make allboards > /dev/null 2>&1
for elf in $(find . -maxdepth 8 | grep 'release' | egrep '\.elf$' | grep -v 'riscv'); do
tmp=${elf#*release/}
b=${tmp%.elf}
./tools/print_tock_memory_usage.py -s ${elf} > current-benchmark-${b}
done

git remote set-branches "$UPSTREAM_REMOTE_NAME" "$GITHUB_BASE_REF" > /dev/null 2>&1
git fetch --depth 1 "$UPSTREAM_REMOTE_NAME" "$GITHUB_BASE_REF" > /dev/null 2>&1
git checkout "$UPSTREAM_REMOTE_NAME"/"$GITHUB_BASE_REF" > /dev/null 2>&1
make allboards > /dev/null 2>&1

# Find elfs compiled for release (for use in analyzing binaries in CI),
# ignore riscv binaries for now because size tool does not support RISC-V
for elf in $(find . -maxdepth 8 | grep 'release' | egrep '\.elf$' | grep -v 'riscv'); do
tmp=${elf#*release/}
b=${tmp%.elf}
./tools/print_tock_memory_usage.py -s ${elf} > previous-benchmark-${b}
done

DIFF_DETECTED=0

# now calculate diff for each board, and post status to github for each non-0 diff
for elf in $(find . -maxdepth 8 | grep 'release' | egrep '\.elf$' | grep -v 'riscv'); do
tmp=${elf#*release/}
b=${tmp%.elf}
# Compute a summary suitable for GitHub.
./tools/diff_memory_usage.py previous-benchmark-${b} current-benchmark-${b} size-diffs-${b}.txt ${b}
if [ -s "size-diffs-${b}.txt" ]; then
DIFF_DETECTED=1
RES="$( grep -hs ^ size-diffs-${b}.txt )" #grep instead of cat to prevent errors on no match
echo "${b}: ${RES}"
fi
# Print a detailed by raw line-by-line diff. Can be useful to
# understand where the size differences come from.
git diff --no-index previous-benchmark-${b} current-benchmark-${b} || true #Supress exit code
done

if [ $DIFF_DETECTED -eq 0 ]; then
echo "-> No size difference on any board detected"
fi