From 839ab9ab02d1c48b42241bcc53d2c6b4484b4bfb Mon Sep 17 00:00:00 2001 From: JianyiCheng Date: Wed, 5 Jul 2023 12:44:13 +0100 Subject: [PATCH 1/2] Added init github ci for building llvm (need script for testing --- .github/workflow/buildAndTest.yml | 58 +++++++++ .github/workflow/format.yml | 204 ++++++++++++++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 .github/workflow/buildAndTest.yml create mode 100644 .github/workflow/format.yml diff --git a/.github/workflow/buildAndTest.yml b/.github/workflow/buildAndTest.yml new file mode 100644 index 0000000..2e78223 --- /dev/null +++ b/.github/workflow/buildAndTest.yml @@ -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 + diff --git a/.github/workflow/format.yml b/.github/workflow/format.yml new file mode 100644 index 0000000..49c2367 --- /dev/null +++ b/.github/workflow/format.yml @@ -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 From 732d2a4fe39c0cafc40b2a08bb8a5a9007b572a1 Mon Sep 17 00:00:00 2001 From: JianyiCheng Date: Wed, 5 Jul 2023 12:48:40 +0100 Subject: [PATCH 2/2] Fixed type in folder name which disable github ci --- .github/{workflow => workflows}/buildAndTest.yml | 0 .github/{workflow => workflows}/format.yml | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/buildAndTest.yml (100%) rename .github/{workflow => workflows}/format.yml (100%) diff --git a/.github/workflow/buildAndTest.yml b/.github/workflows/buildAndTest.yml similarity index 100% rename from .github/workflow/buildAndTest.yml rename to .github/workflows/buildAndTest.yml diff --git a/.github/workflow/format.yml b/.github/workflows/format.yml similarity index 100% rename from .github/workflow/format.yml rename to .github/workflows/format.yml