From 8fa83d8763a4c2cf92e9d1cb37a0543d7a8d1c75 Mon Sep 17 00:00:00 2001 From: unlsycn Date: Mon, 9 Sep 2024 21:19:26 +0800 Subject: [PATCH] [ci] add github ci Signed-off-by: unlsycn --- .github/workflows/daily-bump.yml | 66 ++++++++++++++++++++++++++++ .github/workflows/main.yml | 75 ++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 .github/workflows/daily-bump.yml create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/daily-bump.yml b/.github/workflows/daily-bump.yml new file mode 100644 index 0000000..2424efb --- /dev/null +++ b/.github/workflows/daily-bump.yml @@ -0,0 +1,66 @@ +name: Dependencies Bump +on: + schedule: + # Run this job everyday at 5:30 AM UTC+8 + - cron: '30 21 * * *' + +jobs: + bump-deps: + name: "Bump Chisel and CIRCT" + if: ${{ !cancelled() }} + runs-on: [self-hosted, linux, nixos] + permissions: + contents: write + defaults: + run: + working-directory: ./templates/chisel + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: master + - name: Bump nixpkgs + run: | + nix flake update + - name: Bump Chisel + run: | + cd nix/pkgs/dependencies + nix run '.#nvfetcher' -- -f '^chisel$' + - name: Bump all mill deps + run: | + oldHash=$(nix derivation show .#gcd.gcd-compiled.millDeps | jq -r 'to_entries[0].value.env.outputHash') + nix build '.#gcd.gcd-compiled.millDeps' --rebuild > milldeps-log.txt 2>&1 || true + newHash=$(cat milldeps-log.txt \ + | grep -P '^\s+got:\s+sha256-.*$' \ + | cut -d':' -f2 \ + | xargs) + if [ -z "$newHash" ] || [ "$newHash" = "$oldHash" ]; then + echo "Original build logs for debug: " + cat milldeps-log.txt + echo "Hash unchanged, exit" + exit 0 + fi + echo "Updating hash $oldHash to $newHash" + sed -i "s|$oldHash|$newHash|" nix/gcd/gcd.nix + - name: Commit changes + env: + GITHUB_TOKEN: ${{ secrets.BIYUN_GITHUB_ACTION }} + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + + currentDate=$(date +%F) + branch="dependencies-bumping-$currentDate" + git checkout -b "$branch" + + git add 'nix/pkgs/dependencies' + git add 'flake.lock' + + if ! git diff --quiet --cached --exit-code; then + updatedFiles=$(git diff --cached --name-only) + echo "File changed" + git commit -m "[deps] Bump dependencies" + git push origin "$branch" --force-with-lease + nix run '.#gh' -- \ + pr create --title "Bump dependencies" --body "Updated: $updatedFiles" + fi diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..c65a2ae --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,75 @@ +name: VCS Test +on: + pull_request: + types: + - opened + - synchronize + - reopened + - ready_for_review + - labeled +env: + USER: runner + +# Cancel the current workflow when new commit pushed +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + + build-simulators: + name: "Build Simulators" + runs-on: [self-hosted, linux, nixos, BIGRAM] + strategy: + fail-fast: false + defaults: + run: + working-directory: ./templates/chisel + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: "Build vcs simulator" + run: | + nix build '.#gcd.vcs' --impure + - name: "Build vcs simulator with trace" + run: | + nix build '.#gcd.vcs-trace' --impure + - name: "Build verilator simulator" + run: | + nix build '.#gcd.verilated' + - name: "Build verilator simulator with trace" + run: | + nix build '.#gcd.verilated-trace' + + run-vcs: + name: "Run VCS" + strategy: + fail-fast: false + runs-on: [self-hosted, linux, nixos] + defaults: + run: + working-directory: ./templates/chisel + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: "Run verilator" + run: | + nix run '.#gcd.vcs' --impure + + run-verilator: + name: "Run Verilator" + strategy: + fail-fast: false + runs-on: [self-hosted, linux, nixos] + defaults: + run: + working-directory: ./templates/chisel + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: "Run verilator" + run: | + nix run '.#gcd.verilated'