From 6ba8ed0dda1dd5469477052e406893646506a7c3 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Thu, 8 Aug 2024 23:06:44 -0400 Subject: [PATCH] [wip] ci: switch to GitHub Actions --- .drone.yml | 171 ------------------------------------ .github/workflows/lint.yml | 28 ++++++ .github/workflows/main.yaml | 67 ++++++++++++++ 3 files changed, 95 insertions(+), 171 deletions(-) delete mode 100644 .drone.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/main.yaml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 4d63d317..00000000 --- a/.drone.yml +++ /dev/null @@ -1,171 +0,0 @@ -kind: pipeline -type: docker -name: lint - -steps: - - name: lint - image: golang:1.17 - commands: - - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.47.2 - - golangci-lint run ---- -kind: pipeline -type: exec -name: testing - -platform: - os: linux - arch: amd64 - -workspace: - path: /tmp/drone - -steps: - - name: Build bbi - commands: - - mkdir -p /tmp/${DRONE_BUILD_NUMBER} ; git rev-parse HEAD > /tmp/${DRONE_BUILD_NUMBER}/bbi_hash - - # this is a hack around the current design; will clean up after passing a test or two - - go build -o bbi cmd/bbi/main.go - - ./bbi version - - name: Copy commit hashes to s3 - commands: - - printf "[\n" > /tmp/${DRONE_BUILD_NUMBER}/commits.json - - printf " {\"repo\":\"metrumresearchgroup/bbi\", \"commit\":\"$(cat /tmp/${DRONE_BUILD_NUMBER}/bbi_hash)\"},\n" >> /tmp/${DRONE_BUILD_NUMBER}/commits.json - - printf "]\n" >> /tmp/${DRONE_BUILD_NUMBER}/commits.json - - aws s3 cp /tmp/${DRONE_BUILD_NUMBER}/commits.json s3://mrg-validation/bbi/${DRONE_BUILD_NUMBER}/commits.json - - name: Copy summary info for mrgvalidate to s3 - commands: - - | - cat > /tmp/${DRONE_BUILD_NUMBER}/summary.json <>$GITHUB_PATH + - name: Run golangci-lint + run: golangci-lint run --out-format=github-actions diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..96ae85ba --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,67 @@ +name: CI +on: + push: + branches: + - main + - 'scratch/**' + tags: + - 'v*' + pull_request: + +jobs: + check: + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.os }} (${{ matrix.config.go }}) + strategy: + fail-fast: false + matrix: + config: + - os: ubuntu-20.04 + go: 1.21.x + - os: ubuntu-latest + go: stable + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.config.go }} + - name: Unit tests + shell: bash + run: go list ./... | grep -v integration | xargs go test + - name: Build bbi + shell: bash + run: | + version=$(git rev-parse 'HEAD^{tree}') + bin=$(mktemp -d) + go build -o "$bin/bbi" \ + -ldflags "-X github.com/metrumresearchgroup/bbi/cmd.VERSION=$version" \ + cmd/bbi/main.go + echo "$bin" >>$GITHUB_PATH + - name: Integration tests (postrun) + shell: bash + run: | + bbi version + go test ./integration/postrun + release: + if: github.ref_type == 'tag' + name: Make release + needs: check + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version: stable + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: '~> v2' + args: release --clean + workdir: cmd/bbi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}