http healtcheck proposal/WIP #147
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.run_number || github.event.pull_request.number }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: Run unit tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set VERSION env | |
run: echo "VERSION=$(cat splitio/version.go | grep 'Version =' | awk '{print $4}' | tr -d '"')" >> $GITHUB_ENV | |
- name: Version validation | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: mukunku/[email protected] | |
id: checkTag | |
with: | |
tag: v${{ env.VERSION }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Fail workflow if tag exists | |
if: ${{ github.event_name == 'pull_request' && steps.checkTag.outputs.exists == 'true' }} | |
uses: actions/[email protected] | |
with: | |
script: core.setFailed('[ERROR] Tag already exists.') | |
- name: Setup Go version | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '^1.20.7' | |
- name: Build binaries for host machine | |
run: make splitd splitcli | |
- name: Run tests | |
run: make test | |
- name: Cross build for GNU Linux & Darwin x amd64 & arm64 | |
run: make binaries_release | |
- name: SonarQube Scan | |
uses: SonarSource/[email protected] | |
env: | |
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
projectBaseDir: . | |
args: > | |
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }} | |
-Dsonar.projectVersion=${{ env.VERSION }} | |
- name: Git tag | |
if: ${{ github.event_name == 'push' }} | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
custom_tag: ${{ env.VERSION }} | |
tag_prefix: 'v' | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: ${{ github.event_name == 'push' }} | |
with: | |
name: splitd-${{ env.VERSION }} | |
tag_name: v${{ env.VERSION }} | |
files: | | |
splitd-darwin-amd64-${{ env.VERSION }}.bin | |
splitd-darwin-arm-${{ env.VERSION }}.bin | |
splitd-linux-amd64-${{ env.VERSION }}.bin | |
splitd-linux-amd64-fips-${{ env.VERSION }}.bin | |
splitd-linux-arm-${{ env.VERSION }}.bin |