diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..e657844 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,55 @@ +name: CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + lint-and-test: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: + - "1.22" + env: + GOPRIVATE: github.com/reddit/achilles-sdk-api + + container: + image: golang:${{ matrix.go-version }} + + steps: + - uses: actions/checkout@v3 + + - name: Workaround Git Security Warning + run: | + # Workaround a bug in github actions: + # https://github.com/actions/runner-images/issues/6775. + git config --global --add safe.directory "$GITHUB_WORKSPACE" + + - name: Install SSH key + uses: shimataro/ssh-key-action@v2 + with: + known_hosts: ${{ secrets.KNOWN_HOSTS }} + key: ${{ secrets.GO_MODULE_PRIVATE_KEY }} + + - name: Setup access for private Go modules + run: | + git config --global url."ssh://git@github.com/".insteadOf https://github.com/ + + - name: Generate + run: | + # needed for running `tar -xJv` for installing shellcheck + apt-get update + apt-get install xz-utils + + make generate + test -z '$(git status --porcelain)' || (echo "'make generate' made modifications. ensure 'make generate' has been run:"; git status -s; git --no-pager diff; false) + + # lint code + make lint + test -z '$(git status --porcelain)' || (echo "'make lint' made modifications. ensure 'make lint' has been run:"; git status -s; git --no-pager diff; false) + + - name: Test + run: make test