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

Use GitHub Actions for CI (attempt 2) #2465

Merged
merged 11 commits into from
May 15, 2020
176 changes: 176 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# This file describes the GitHub Actions workflow for continuous integration of rocket-chip.
#
# See
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# for API reference documentation on this file format.

name: Continuous Integration

on:
push:
branches:
- master
pull_request:
branches:
- master


jobs:
check-wit:
name: Check Wit Manifest
runs-on: ubuntu-16.04
steps:
- uses: actions/checkout@v2
- run: ci-tests/check_submodules


prepare-riscv-tools-cache:
name: Prepare riscv-tools Cache
runs-on: ubuntu-16.04
steps:
- uses: actions/checkout@v2

- id: cache
# We use an unreleased version of the cache action that adds support for
# multiple paths to cache. This can be changed to a normal version
# number (likely v2) once it is released. See
# https://github.com/actions/cache/pull/212
uses: actions/cache@eb78578266b7cec649ab65b6f1534bd6040c838b
with:
path: |
./regression/install
./regression/stamps/rocket-tools_checkout.stamp
key: riscv-tools-${{ hashFiles('./riscv-tools.hash') }}-v1

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
sudo apt-get install -y \
autoconf \
automake \
autotools-dev \
bison \
build-essential \
device-tree-compiler \
flex \
g++-4.8 \
gawk \
gcc-4.8 \
gperf \
libgmp-dev \
libmpc-dev \
libmpfr-dev \
libusb-1.0-0-dev \
texinfo

- if: steps.cache.outputs.cache-hit != 'true'
env:
CXX: g++-4.8
CC: gcc-4.8
run: make tools -C regression SUITE=none


prepare-verilator-cache:
name: Prepare Verilator Cache
runs-on: ubuntu-16.04
steps:
- uses: actions/checkout@v2

# TODO: Use v2 once it is released. See the first occurrance of
# actions/cache in this file for more details.
- uses: actions/cache@eb78578266b7cec649ab65b6f1534bd6040c838b
with:
path: ./emulator/verilator
key: verilator-${{ hashFiles('./verilator.hash') }}-v1

# WARNING: The version of gcc used to compile Verilator MUST match the
# version of gcc used to compile the fesvr. There is some bug related to
# some C struct not being ABI-compatible across gcc 4 and 5, which we have
# not debugged yet.
- name: Install Dependencies
run: sudo apt-get install -y autoconf bison flex g++-4.8 gcc-4.8

- env:
CXX: g++-4.8
CC: gcc-4.8
run: make verilator -C regression SUITE=none


check-wake-compilation:
name: Check Wake Compilation
runs-on: ubuntu-16.04
steps:
- uses: actions/checkout@v2

- name: Use SBT Cache
# TODO: Use v2 once it is released. See the first occurrance of
# actions/cache in this file for more details.
uses: actions/cache@eb78578266b7cec649ab65b6f1534bd6040c838b
with:
path: |
~/.cache/coursier
~/.sbt
key: sbt-${{ hashFiles('**/build.sbt') }}-v1

- run: ci-tests/wake_scala_compilation

# This job is defined as a matrix job, where the definitions of each test
# bucket is located in a shell script at ./regression/run-test-bucket.
test:
name: Test
runs-on: ubuntu-16.04
needs: [prepare-riscv-tools-cache, prepare-verilator-cache]
strategy:
fail-fast: false
matrix:
bucket: [1, 2, 3, 4, 5, 6, 7]
steps:
- uses: actions/checkout@v2

- name: Use riscv-tools Cache
# TODO: Use v2 once it is released. See the first occurrance of
# actions/cache in this file for more details.
uses: actions/cache@eb78578266b7cec649ab65b6f1534bd6040c838b
with:
path: |
./regression/install
./regression/stamps/rocket-tools_checkout.stamp
key: riscv-tools-${{ hashFiles('./riscv-tools.hash') }}-v1

- name: Use Verilator Cache
# TODO: Use v2 once it is released. See the first occurrance of
# actions/cache in this file for more details.
uses: actions/cache@eb78578266b7cec649ab65b6f1534bd6040c838b
with:
path: ./emulator/verilator
key: verilator-${{ hashFiles('./verilator.hash') }}-v1

- name: Use SBT Cache
# TODO: Use v2 once it is released. See the first occurrance of
# actions/cache in this file for more details.
uses: actions/cache@eb78578266b7cec649ab65b6f1534bd6040c838b
with:
path: |
~/.cache/coursier
~/.sbt
key: sbt-${{ hashFiles('**/build.sbt') }}-v1

- name: Install Dependencies
run: |
sudo apt-get install -y \
device-tree-compiler \
g++-4.8 \
gcc-4.8
python3 -m pip install pexpect==4.3.1

- env:
CXX: g++-4.8
CC: gcc-4.8
run: ./regression/run-test-bucket ${{ matrix.bucket }}

- if: failure()
name: Upload Artifacts on Failure
uses: actions/upload-artifact@v1
with:
name: test-bucket-${{ matrix.bucket }}-failures
path: emulator/output
27 changes: 7 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,38 +77,25 @@ jobs:
- &test
stage: Test
script:
- travis_wait 100 make emulator-ndebug -C regression SUITE=UnittestSuite JVM_MEMORY=3G VERILATOR_THREADS=1
- travis_wait 100 make emulator-regression-tests -C regression SUITE=UnittestSuite JVM_MEMORY=3G VERILATOR_THREADS=1
- ./regression/run-test-bucket 1
- <<: *test
script:
- travis_wait 80 make emulator-ndebug -C regression SUITE=JtagDtmSuite JVM_MEMORY=3G
- travis_wait 80 make emulator-jtag-dtm-tests-32 -C regression SUITE=JtagDtmSuite JVM_MEMORY=3G
- travis_wait 80 make emulator-jtag-dtm-tests-64 -C regression SUITE=JtagDtmSuite JVM_MEMORY=3G
- travis_wait 80 make emulator-jtag-dtm-tests-32 -C regression SUITE=JtagDtmSuite JTAG_DTM_TEST=DebugTest JVM_MEMORY=3G
- travis_wait 80 make emulator-jtag-dtm-tests-64 -C regression SUITE=JtagDtmSuite JTAG_DTM_TEST=DebugTest JVM_MEMORY=3G
- ./regression/run-test-bucket 2
- <<: *test
script:
- travis_wait 80 make emulator-ndebug -C regression SUITE=JtagDtmSuite JTAG_DTM_ENABLE_SBA=on JVM_MEMORY=3G
- travis_wait 80 make emulator-jtag-dtm-tests-32 -C regression SUITE=JtagDtmSuite JTAG_DTM_TEST=MemTest64 JTAG_DTM_ENABLE_SBA=on JVM_MEMORY=3G
- travis_wait 80 make emulator-jtag-dtm-tests-64 -C regression SUITE=JtagDtmSuite JTAG_DTM_TEST=MemTest64 JTAG_DTM_ENABLE_SBA=on JVM_MEMORY=3G
- travis_wait 80 make emulator-jtag-dtm-tests-32 -C regression SUITE=JtagDtmSuite JTAG_DTM_TEST=MemTest32 JTAG_DTM_ENABLE_SBA=on JVM_MEMORY=3G
- travis_wait 80 make emulator-jtag-dtm-tests-64 -C regression SUITE=JtagDtmSuite JTAG_DTM_TEST=MemTest32 JTAG_DTM_ENABLE_SBA=on JVM_MEMORY=3G
- travis_wait 80 make emulator-jtag-dtm-tests-32 -C regression SUITE=JtagDtmSuite JTAG_DTM_TEST=MemTest8 JTAG_DTM_ENABLE_SBA=on JVM_MEMORY=3G
- ./regression/run-test-bucket 3
- <<: *test
script:
- travis_wait 80 make emulator-ndebug -C regression SUITE=RocketSuiteB JVM_MEMORY=3G
- travis_wait 80 make emulator-regression-tests -C regression SUITE=RocketSuiteB JVM_MEMORY=3G
- ./regression/run-test-bucket 4
- <<: *test
script:
- travis_wait 80 make emulator-ndebug -C regression SUITE=RocketSuiteA JVM_MEMORY=3G
- travis_wait 80 make emulator-regression-tests -C regression SUITE=RocketSuiteA JVM_MEMORY=3G
- ./regression/run-test-bucket 5
- <<: *test
script:
- travis_wait 80 make emulator-ndebug -C regression SUITE=RocketSuiteC JVM_MEMORY=3G
- make emulator-regression-tests -C regression SUITE=RocketSuiteC JVM_MEMORY=3G
- ./regression/run-test-bucket 6
- <<: *test
script:
- travis_wait 80 make emulator-ndebug -C regression SUITE=Miscellaneous JVM_MEMORY=3G
- ./regression/run-test-bucket 7
- <<: *test
name: check wake compilation
script:
Expand Down
61 changes: 61 additions & 0 deletions README_GITHUB_ACTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# GitHub Actions Notes for Maintainers

rocket-chip makes use of [GitHub Actions](https://github.com/features/actions)
for running continuous integration (CI) tests. For more information on GitHub
Actions, please see their [documentation](https://help.github.com/en/actions).


## How It Is Configured

The main configuration file describing the continuous integration workflow is
located at
[.github/workflows/continuous-integration.yml](.github/workflows/continuous-integration.yml).
This sets up a few jobs for prebuilding and caching a few tools, such as the
riscv-tools and Verilator, as well as a large matrix job that runs the suite of
tests in parallel.

The actual Makefile targets run as part of the test suites defined in
[regression/run-test-bucket](regression/run-test-bucket).

For information on the Workflow file syntax, please see the
[API reference](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions).


## Caching

Caching is handled by the official GitHub Action [actions/cache](https://github.com/marketplace/actions/cache).
Caches are kept around for one week, and caches are searched in order branch,
base branch (e.g. PR target), and default branch (e.g. master).

See the [general GitHub Actions documentation on caching](https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows)
or the [GitHub repository for actions/cache](https://github.com/actions/cache)
for more information.

### Force Invalidating the riscv-tools or Verilator Caches

Normally there is no need to manually invalidate the caches, since they are
automatically invalidated if either [riscv-tools.hash](riscv-tools.hash) or
[verilator.hash](verilator.hash) changes. However, there are situations where
you may need to manually invalidate the caches.

[There is no way to delete a cache](https://github.com/actions/cache/issues/294),
so the recommended approach for invalidating a cache is to modify the cache key.
In the rocket-chip GitHub Action workflow configuration file, the cache keys
each end in `-v#`, where `#` is a number. These numbers can be incremented to
"invalidate" the cache. Each key needs to be updated in all places that it
occurs in the file.

Below are step-by-step instructions for invalidating the riscv-tools cache
(similar instructions will apply to the other caches):

1. Open [.github/workflows/continuous-integration.yml](.github/workflows/continuous-integration.yml)
2. Under the `prepare-riscv-tools-cache` job, locate the step that defines the cache.
It can be identified by finding the step which contains `uses: actions/cache@*`.
3. Locate the cache key, which is defined under the `key` property.
Notice that the key ends with something like `-v1`.
The number in the key may have changed since this documentation was written.
4. Increment the number, e.g. change the key to end in `-v2`.
5. Locate all other usages of that cache key within the file, and similarly
increment the number at the end to match.
6. Commit these changes and push them to GitHub, which should automatically run
and detect that you have a new cache key.
2 changes: 1 addition & 1 deletion emulator/Makefrag-verilator
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $(generated_dir)/$(long_name).behav_srams.v : $(generated_dir)/$(long_name).conf
mv -f $@.tmp $@

# Build and install our own Verilator, to work around versionining issues.
VERILATOR_VERSION=4.028
VERILATOR_VERSION ?= $(shell cat $(base_dir)/verilator.hash)
VERILATOR_SRCDIR ?= verilator/src/verilator-$(VERILATOR_VERSION)
VERILATOR_TARGET := $(abspath verilator/install/bin/verilator)
INSTALLED_VERILATOR ?= $(VERILATOR_TARGET)
Expand Down
14 changes: 7 additions & 7 deletions regression/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,15 @@ stamps/other-submodules.stamp:
git -C $(abspath $(TOP)) submodule update --init --recursive $(submodule_names)
date > $@

stamps/rocket-tools_checkout.stamp:
mkdir -p $(dir $@)
stamps/riscv-tests.stamp:
git -C $(abspath $(TOP)) clone -n https://github.com/freechipsproject/rocket-tools.git
git -C $(RISCV_TOOLS) checkout $(TOOLS_HASH)
git -C $(RISCV_TOOLS) submodule update --init --recursive riscv-isa-sim riscv-tests riscv-pk riscv-openocd fsf-binutils-gdb
git -C $(RISCV_TOOLS) submodule update --init --recursive riscv-tests
mkdir -p $(dir $@)
date > $@

stamps/rocket-tools_checkout.stamp: | stamps/riscv-tests.stamp
git -C $(RISCV_TOOLS) submodule update --init --recursive riscv-isa-sim riscv-pk riscv-openocd fsf-binutils-gdb
git -C $(RISCV_TOOLS) submodule update --init riscv-gnu-toolchain
git -C $(RISCV_TOOLS)/riscv-gnu-toolchain submodule update --init riscv-binutils-gdb riscv-gcc riscv-newlib
rm -f $(RISCV_TOOLS)/.travis.yml
Expand Down Expand Up @@ -275,10 +279,6 @@ endif

JTAG_DTM_SIM_ARGS = +verbose +jtag_rbb_enable=1 $(SEED_ARG)

stamps/riscv-tests.stamp: stamps/rocket-tools_checkout.stamp
mkdir -p $(dir $@)
date > $@

stamps/%/vsim-jtag-dtm-32-$(JTAG_DTM_TEST).stamp: stamps/%/vsim$(JTAG_STAMP_SUFFIX).stamp stamps/riscv-tests.stamp
RISCV=$(RISCV) PATH="$(abspath $(RISCV)/bin:$(PATH))" $(GDBSERVER) \
--sim_cmd="$(abspath $(TOP))/vsim/simv-$(PROJECT)-$*$(JTAG_DEBUG_SUFFIX) $(JTAG_DTM_SIM_ARGS) $(VSIM_JTAG_VCDPLUS_32)" \
Expand Down
Loading