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

Added init github CI for building llvm (need script for testing #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
58 changes: 58 additions & 0 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build and Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build-with-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: "true"

# -----------
# Build SIMTight
# -----------

- name: Get dependences
run: |
sudo apt-get update
sudo apt-get install apt-utils -y

# Install basic packages
sudo apt-get install -y verilator gcc-riscv64-unknown-elf \
libgmp-dev python3 python3-pip g++\
clang llvm lld clang-tidy clang-format \
gcc-multilib gcc cmake sudo wget vim \
curl tmux git bc

# Install cheribuild dependencies
sudo apt-get install -y autoconf automake libtool pkg-config \
clang bison cmake mercurial ninja-build \
samba flex texinfo time libglib2.0-dev \
libpixman-1-dev libarchive-dev libarchive-tools \
libbz2-dev libattr1-dev libcap-ng-dev \
libexpat1-dev libgmp-dev

pip3 install --user --upgrade pip
pip3 install black colorlog toml tabulate isort

- name: Install GHC
run: |
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
BOOTSTRAP_HASKELL_GHC_VERSION=latest \
BOOTSTRAP_HASKELL_CABAL_VERSION=latest \
BOOTSTRAP_HASKELL_INSTALL_STACK=1 \
BOOTSTRAP_HASKELL_INSTALL_HLS=1 \
BOOTSTRAP_HASKELL_ADJUST_BASHRC=P sh

- name: Build cheri-llvm
run: |
bash scripts/build-cheri.sh

204 changes: 204 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
name: Code formatting check

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build-with-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: "true"

# -----------
# Format check
# -----------

- name: Check missing breakpoint
run: |
if [[ $(grep -rnw ./software/machop -e "breakpoint()") -eq 1 ]]; then
echo "Found undeleted breakpoint:"
grep -rnw ./software/machop -e "breakpoint()"
exit 1
fi

- name: Install black and clang
run: |
sudo apt-get install -y \
python3 python3-pip clang-format clang-tidy
pip3 install --user --upgrade pip
pip3 install black

# Run black to check Python formatting.
- name: python-format
if: ${{ always() }}
shell: bash
run: |
files=$(git diff --name-only $DIFF_COMMIT | grep -e '\.py$' || echo -n)
if [[ ! -z $files ]]; then
for f in $files
do
if [[ -f $f ]]; then
python3 -m black $f
fi
done
fi

- name: Install Verible
run: |
# Install SystemVerilog formatter
(mkdir -p "${HOME}"/srcPkgs \
&& cd "${HOME}"/srcPkgs \
&& wget https://github.com/chipsalliance/verible/releases/download/v0.0-2776-gbaf0efe9/verible-v0.0-2776-gbaf0efe9-Ubuntu-22.04-jammy-x86_64.tar.gz \
&& mkdir -p verible \
&& tar xzvf verible-*-x86_64.tar.gz -C verible --strip-components 1)
ln -s "${HOME}"/srcPkgs/verible/bin/verible-verilog-format /usr/local/bin/verible-verilog-format
ln -s "${HOME}"/srcPkgs/verible/bin/verible-verilog-diff /usr/local/bin/verible-verilog-diff
ln -s "${HOME}"/srcPkgs/verible/bin/git-verible-verilog-format.sh /usr/local/bin/git-verible-verilog-format.sh

# Run verible-verilog-format to check Verilog/SystemVerilog formatting.
- name: verilog-format
if: ${{ always() }}
shell: bash
run: |
files=$(git diff --name-only $DIFF_COMMIT | grep -e '\.sv$' || echo -n)
if [[ ! -z $files ]]; then
for f in $files
do
if [[ -f $f ]]; then
verible-verilog-format $f | diff - $f
fi
done
fi
files=$(git diff --name-only $DIFF_COMMIT | grep -e '\.v$' || echo -n)
if [[ ! -z $files ]]; then
for f in $files
do
if [[ -f $f ]]; then
verible-verilog-format $f | diff - $f
fi
done
fi

# Choose the git commit to diff against for the purposes of linting.
# Since this workflow is triggered on both pushes and pull requests, w
# have to determine if the pull request target branch is set (which it
# will only be on the PR triggered flow). If it's not, then compare
# against the last commit.
- name: choose-commit
if: ${{ always() }}
env:
# Base ref is the target branch, in text form (not hash)
PR_BASE: ${{ github.base_ref }}
run: |
# Run clang-format
if [ -z "$PR_BASE" ]; then
DIFF_COMMIT_NAME="HEAD^"
else
DIFF_COMMIT_NAME="$PR_BASE"
fi
echo "DIFF_COMMIT_NAME=$DIFF_COMMIT_NAME" >> $GITHUB_ENV

# Since we did a shallow fetch for this repo, we must fetch the commit
# upon which we be diff'ing. The last step set the ref name in the
# $DIFF_COMMIT_NAME environment variable. When running the fetch, resolve
# it to the commit hash and pass that hash along to subsequent steps.
- name: git fetch base commit
continue-on-error: true
run: |
if echo "$DIFF_COMMIT_NAME" | grep -q HEAD; then
DIFF_COMMIT_SHA=$( git rev-parse $DIFF_COMMIT_NAME )
else
git fetch --recurse-submodules=no origin $DIFF_COMMIT_NAME
DIFF_COMMIT_SHA=$( git rev-parse origin/$DIFF_COMMIT_NAME )
fi
echo "DIFF_COMMIT=$DIFF_COMMIT_SHA" >> $GITHUB_ENV

# Run 'git clang-format', comparing against the target commit hash. If
# clang-format fixed anything, fail and output a patch.
- name: clang-format
if: ${{ always() }}
run: |
# Run clang-format
git clang-format $DIFF_COMMIT
git diff --ignore-submodules > clang-format.patch
if [ -s clang-format.patch ]; then
echo "Clang-format found formatting problems in the following " \
"files. See diff in the clang-format.patch artifact."
git diff --ignore-submodules --name-only
git checkout .
exit 1
fi
echo "Clang-format found no formatting problems"
exit 0

# Upload the format patches to an artifact (zip'd) associated
# with the workflow run. Only run this on a failure.
- name: Upload format patches
uses: actions/upload-artifact@v2
continue-on-error: true
if: ${{ failure() }}
with:
name: clang-format-patches
path: clang-*.patch

# Unfortunately, artifact uploads are always zips so display the diff as
# well to provide feedback at a glance.
- name: clang format patches display
if: ${{ failure() }}
continue-on-error: true
run: |
# Display patches
if [ ! -z clang-format.patch ]; then
echo "Clang-format patch"
echo "================"
cat clang-format.patch
echo "================"
fi

# Run clang-tidy against only the changes. The 'clang-tidy-diff' script
# does this if supplied with the diff.
- name: clang-tidy
if: ${{ always() }}
run: |
git diff -U0 $DIFF_COMMIT...HEAD | \
clang-tidy-diff -path build -p1 -fix -j$(nproc)
git clang-format -f $DIFF_COMMIT
git diff --ignore-submodules > clang-tidy.patch
if [ -s clang-tidy.patch ]; then
echo "Clang-tidy problems in the following files. " \
"See diff in the clang-tidy.patch artifact."
git diff --ignore-submodules --name-only
git checkout .
exit 1
fi
echo "Clang-tidy found no problems"
exit 0

# Upload the tidy patches to an artifact (zip'd) associated
# with the workflow run. Only run this on a failure.
- name: Upload tidy patches
uses: actions/upload-artifact@v2
continue-on-error: true
if: ${{ failure() }}
with:
name: clang-tidy-patches
path: clang-*.patch

# Unfortunately, artifact uploads are always zips so display the diff as
# well to provide feedback at a glance.
- name: clang tidy patches display
if: ${{ failure() }}
continue-on-error: true
run: |
if [ ! -z clang-tidy.patch ]; then
echo "Clang-tidy patch"
echo "================"
cat clang-tidy.patch
echo "================"
fi