Files
sablier/.github/workflows/build.yml
Alexis Couvreur 13fc346a89 ci: add go binary diff (#562)
* ci: add go binary diff

* copilot fix :)

* print the diff in a code block

* fix yaml

* fix eof

* use cat command
2025-03-12 22:47:16 -04:00

90 lines
2.5 KiB
YAML

name: Build
on:
push:
branches:
- main
- beta
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
build:
name: Build
permissions:
contents: read
id-token: write # OIDC with Codecov
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go 1.24
uses: actions/setup-go@v5
with:
go-version: ^1.24
cache-dependency-path: go.sum
- name: Build
run: make
- name: Test
run: go test -v -json -race -covermode atomic -coverprofile coverage.txt ./... 2>&1 | go tool go-junit-report -parser gojson -set-exit-code > junit.xml
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: acouvreur/codecov-action@main
with:
use_oidc: true
fail_ci_if_error: true
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
use_oidc: true
fail_ci_if_error: true
- name: Run Basic Test Results Action
if: ${{ !cancelled() }}
uses: codecov/basic-test-results@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: junit.xml
disable-search: true
# TODO: Download release asset action with cache
- name: Download latest released Sablier binary
if: ${{ !cancelled() }}
id: latest-release
run: |
release_data=$(curl -s https://api.github.com/repos/sablierapp/sablier/releases/latest)
artifact_url=$(echo $release_data | jq -r '.assets[] | select(.name | contains("linux-amd64")) | .browser_download_url')
version=$(echo $release_data | jq -r '.tag_name')
wget -q $artifact_url -O sablier_${version}_linux-amd64
echo "artifact_path=sablier_${version}_linux-amd64" >> $GITHUB_OUTPUT
- name: Compare the downloaded binary with the built binary
if: ${{ !cancelled() }}
id: diff
run: |
go tool gsa -o diff.txt ${{ steps.latest-release.outputs.artifact_path }} sablier_draft_linux-amd64
echo "diff<<EOF" >> $GITHUB_OUTPUT
echo "$(cat diff.txt)" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Comment diff on pull request
if: ${{ !cancelled() }}
uses: thollander/actions-comment-pull-request@v3
with:
message: |
```
${{ steps.diff.outputs.diff }}
```
comment-tag: go-binary-diff