## Description An attempt to minimize and centralize how we're caching go builds. Not necessarily going to solve all our CI issues, but should make changes building on this state much easier. ## Type of change - [x] 💻 CI/Deployment ## Issue(s) * #790 ## Test Plan - [ ] 💪 Manual - [ ] ⚡ Unit test - [x] 💚 E2E
135 lines
4.8 KiB
YAML
135 lines
4.8 KiB
YAML
name: CI Tests
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
# required to retrieve AWS credentials
|
|
id-token: write
|
|
contents: read
|
|
pull-requests: read
|
|
|
|
# cancel currently running jobs if a new version of the branch is pushed
|
|
concurrency:
|
|
group: ci-linting-${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
|
# --- Prechecks and Checkouts ------------------------------------------------------------------------
|
|
# ----------------------------------------------------------------------------------------------------
|
|
precheck:
|
|
uses: alcionai/corso/.github/workflows/_filechange_checker.yml@main
|
|
|
|
checkout:
|
|
needs: precheck
|
|
environment: Testing
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
# single setup and sum cache handling here.
|
|
# the results will cascade onto both testing and linting.
|
|
- name: Setup Golang with cache
|
|
if: needs.precheck.outputs.fileschanged == 'true'
|
|
uses: magnetikonline/action-golang-cache@v3
|
|
with:
|
|
go-version-file: src/go.mod
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
|
# --- Integration and Unit Testing -------------------------------------------------------------------
|
|
# ----------------------------------------------------------------------------------------------------
|
|
|
|
Test-Suite:
|
|
needs: [precheck, checkout]
|
|
environment: Testing
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: src
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup Golang with cache
|
|
if: needs.precheck.outputs.fileschanged == 'true'
|
|
uses: magnetikonline/action-golang-cache@v3
|
|
with:
|
|
go-version-file: src/go.mod
|
|
|
|
# Install gotestfmt
|
|
- name: Set up gotestfmt
|
|
if: needs.precheck.outputs.fileschanged == 'true'
|
|
run: go install github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@latest
|
|
|
|
# AWS creds
|
|
- name: Configure AWS credentials from Test account
|
|
if: needs.precheck.outputs.fileschanged == 'true'
|
|
uses: aws-actions/configure-aws-credentials@v1
|
|
with:
|
|
role-to-assume: arn:aws:iam::951767375776:role/corso-testing-role
|
|
role-session-name: integration-testing
|
|
aws-region: us-east-1
|
|
|
|
# run the tests
|
|
- name: Integration Tests
|
|
if: needs.precheck.outputs.fileschanged == 'true'
|
|
env:
|
|
CLIENT_ID: ${{ secrets.CLIENT_ID }}
|
|
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
|
|
CORSO_CI_TESTS: true
|
|
CORSO_M356_TEST_USER_ID: ${{ secrets.CORSO_M356_TEST_USER_ID }}
|
|
CORSO_PASSPHRASE: ${{ secrets.INTEGRATION_TEST_CORSO_PASSPHRASE }}
|
|
RUDDERSTACK_CORSO_WRITE_KEY: ${{ secrets.RUDDERSTACK_CORSO_WRITE_KEY }}
|
|
RUDDERSTACK_CORSO_DATA_PLANE_URL: ${{ secrets.RUDDERSTACK_CORSO_DATA_PLANE_URL }}
|
|
TENANT_ID: ${{ secrets.TENANT_ID }}
|
|
run: |
|
|
set -euo pipefail
|
|
go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt -hide successful-tests
|
|
|
|
# Upload the original go test log as an artifact for later review.
|
|
- name: Upload test log
|
|
if: needs.precheck.outputs.fileschanged == 'true'
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: test-log
|
|
path: /tmp/gotest.log
|
|
if-no-files-found: error
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
|
# --- Source Code Linting ----------------------------------------------------------------------------
|
|
# ----------------------------------------------------------------------------------------------------
|
|
|
|
Linting:
|
|
needs: [precheck, checkout]
|
|
environment: Testing
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: src
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup Golang with cache
|
|
if: needs.precheck.outputs.fileschanged == 'true'
|
|
uses: magnetikonline/action-golang-cache@v3
|
|
with:
|
|
go-version-file: src/go.mod
|
|
|
|
- name: Go Lint
|
|
if: needs.precheck.outputs.fileschanged == 'true'
|
|
uses: golangci/golangci-lint-action@v3.2.0
|
|
with:
|
|
version: v1.45.2
|
|
working-directory: ./src
|
|
|
|
# check licenses
|
|
- name: Get go-licenses
|
|
if: needs.precheck.outputs.fileschanged == 'true'
|
|
run: go install github.com/google/go-licenses@latest
|
|
|
|
- name: Run go-licenses
|
|
if: needs.precheck.outputs.fileschanged == 'true'
|
|
run: go-licenses check github.com/alcionai/corso/src --ignore github.com/alcionai/corso/src |