linux.yml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. name: Linux
  2. on:
  3. push:
  4. branches:
  5. - main
  6. pull_request:
  7. branches:
  8. - '*'
  9. jobs:
  10. build:
  11. runs-on: ubuntu-latest
  12. if: "!contains(github.event.head_commit.message, '[ci skip]')"
  13. steps:
  14. - name: Set up Go
  15. uses: actions/[email protected]
  16. with:
  17. go-version: 1.17
  18. id: go
  19. - name: Check out code into the Go module directory
  20. uses: actions/checkout@v1
  21. - name: Basic build
  22. run: go build ./cmd/...
  23. - name: Get QEMU
  24. run: |
  25. # The qemu in Ubuntu 20.04 (Focal) is too old; we need 5.x something
  26. # to run Go binaries. 5.2.0 (Debian bullseye) empirically works, and
  27. # use this PPA which brings in a modern qemu.
  28. sudo add-apt-repository -y ppa:jacob/virtualisation
  29. sudo apt-get -y update
  30. sudo apt-get -y install qemu-user
  31. - name: Run tests on linux
  32. run: go test -bench=. -benchtime=1x ./...
  33. - name: Check that no tracked files in the repo have been modified
  34. run: git diff --no-ext-diff --name-only --exit-code || (echo "Build/test modified the files above."; exit 1)
  35. - name: Check that no files have been added to the repo
  36. run: |
  37. # Note: The "error: pathspec..." you see below is normal!
  38. # In the success case in which there are no new untracked files,
  39. # git ls-files complains about the pathspec not matching anything.
  40. # That's OK. It's not worth the effort to suppress. Please ignore it.
  41. if git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- ':/*'
  42. then
  43. echo "Build/test created untracked files in the repo (file names above)."
  44. exit 1
  45. fi
  46. - uses: k0kubun/[email protected]
  47. with:
  48. payload: |
  49. {
  50. "attachments": [{
  51. "text": "${{ job.status }}: ${{ github.workflow }} <https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks|${{ env.COMMIT_DATE }} #${{ env.COMMIT_NUMBER_OF_DAY }}> " +
  52. "(<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|" + "${{ github.sha }}".substring(0, 10) + ">) " +
  53. "of ${{ github.repository }}@" + "${{ github.ref }}".split('/').reverse()[0] + " by ${{ github.event.head_commit.committer.name }}",
  54. "color": "danger"
  55. }]
  56. }
  57. env:
  58. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  59. if: failure() && github.event_name == 'push'