From 0a2f98224c1aa999d7776db0433a862c01ee125a Mon Sep 17 00:00:00 2001 From: Harvey Xia Date: Tue, 29 Oct 2024 11:44:20 -0400 Subject: [PATCH] add CI --- .github/workflows/ci.yaml | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/ci.yaml 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