improve ci cache management - initial cleanup (#849)
## 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
This commit is contained in:
parent
e92cb1b62b
commit
a368570e20
108
.github/workflows/ci.yml
vendored
108
.github/workflows/ci.yml
vendored
@ -17,61 +17,47 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
# --- Prechecks and Checkouts ------------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
precheck:
|
||||
uses: alcionai/corso/.github/workflows/_filechange_checker.yml@main
|
||||
|
||||
Test-Suite:
|
||||
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:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
# Get values for cache paths to be used in later steps
|
||||
- name: Local Cache Setup
|
||||
- name: Setup Golang with cache
|
||||
if: needs.precheck.outputs.fileschanged == 'true'
|
||||
id: go-cache-paths
|
||||
run: |
|
||||
echo "::set-output name=go-build::$(go env GOCACHE)"
|
||||
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
|
||||
|
||||
- name: Golang Setup
|
||||
if: needs.precheck.outputs.fileschanged == 'true'
|
||||
uses: actions/setup-go@v3
|
||||
uses: magnetikonline/action-golang-cache@v3
|
||||
with:
|
||||
go-version: 1.18
|
||||
cache: true
|
||||
cache-dependency-path: src/go.sum
|
||||
|
||||
# download packages
|
||||
- name: Cache Go Mod
|
||||
if: needs.precheck.outputs.fileschanged == 'true'
|
||||
id: modcache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.go-cache-paths.outputs.go-mod }}
|
||||
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
- name: Run go mod download
|
||||
if: needs.precheck.outputs.fileschanged == 'true' && steps.modcache.outputs.cache-hit != 'true'
|
||||
run: go mod download
|
||||
|
||||
# build the binary
|
||||
- name: Cache Go build
|
||||
if: needs.precheck.outputs.fileschanged == 'true'
|
||||
id: gocache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.go-cache-paths.outputs.go-build }}
|
||||
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
- name: Go build
|
||||
if: needs.precheck.outputs.fileschanged == 'true' && steps.gocache.outputs.cache-hit != 'true'
|
||||
run: go build -v ./...
|
||||
go-version-file: src/go.mod
|
||||
|
||||
# Install gotestfmt
|
||||
- name: Set up gotestfmt
|
||||
@ -110,4 +96,40 @@ jobs:
|
||||
with:
|
||||
name: test-log
|
||||
path: /tmp/gotest.log
|
||||
if-no-files-found: error
|
||||
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
|
||||
88
.github/workflows/lint.yml
vendored
88
.github/workflows/lint.yml
vendored
@ -1,88 +0,0 @@
|
||||
name: Lint
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
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:
|
||||
precheck:
|
||||
uses: alcionai/corso/.github/workflows/_filechange_checker.yml@main
|
||||
|
||||
Linting:
|
||||
needs: precheck
|
||||
environment: Testing
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: src
|
||||
steps:
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Get values for cache paths to be used in later steps
|
||||
- name: Local Cache Setup
|
||||
if: needs.precheck.outputs.fileschanged == 'true'
|
||||
id: go-cache-paths
|
||||
run: |
|
||||
echo "::set-output name=go-build::$(go env GOCACHE)"
|
||||
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
|
||||
|
||||
- name: Golang Setup
|
||||
if: needs.precheck.outputs.fileschanged == 'true'
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.18
|
||||
|
||||
- name: Cache Go Mod
|
||||
if: needs.precheck.outputs.fileschanged == 'true'
|
||||
id: modcache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
- name: Download package dependencies
|
||||
if: needs.precheck.outputs.fileschanged == 'true' && steps.modcache.outputs.cache-hit != 'true'
|
||||
run: go mod download
|
||||
|
||||
- name: Cache Go build
|
||||
if: needs.precheck.outputs.fileschanged == 'true'
|
||||
id: gocache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cache/go-build
|
||||
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
- name: Build for Lint
|
||||
if: needs.precheck.outputs.fileschanged == 'true' && steps.gocache.outputs.cache-hit != 'true'
|
||||
run: go build ./...
|
||||
|
||||
- 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
|
||||
skip-pkg-cache: true
|
||||
skip-build-cache: true
|
||||
skip-go-installation: 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
|
||||
Loading…
x
Reference in New Issue
Block a user