## Description Attempting to fix cache control. ## Type of change - [x] 💻 CI/Deployment ## Issue(s) * #790 ## Test Plan - [x] 💪 Manual
141 lines
4.7 KiB
YAML
141 lines
4.7 KiB
YAML
name: CI Tests
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
# required to retrieve AWS credentials
|
|
id-token: write
|
|
contents: write
|
|
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
|
|
defaults:
|
|
run:
|
|
working-directory: src
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup Golang with cache
|
|
if: needs.precheck.outputs.fileschanged == 'true'
|
|
uses: ./.github/actions/go-setup-cache
|
|
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
|
|
|
|
- run: mkdir testlog
|
|
|
|
# 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 }}
|
|
TENANT_ID: ${{ secrets.TENANT_ID }}
|
|
run: |
|
|
set -euo pipefail
|
|
go test \
|
|
-json \
|
|
-v \
|
|
./... 2>&1 | tee ./testlog/gotest.log | gotestfmt -hide successful-tests
|
|
|
|
# Upload the original go test log as an artifact for later review.
|
|
- name: Upload test log
|
|
if: failure() && needs.precheck.outputs.fileschanged == 'true'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: test-log
|
|
path: testlog/gotest.log
|
|
if-no-files-found: error
|
|
retention-days: 14
|
|
|
|
# ----------------------------------------------------------------------------------------------------
|
|
# --- 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
|
|
with:
|
|
version: v1.45.2
|
|
working-directory: src
|
|
skip-cache: true
|
|
|
|
# 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 |