CI job to run unit tests without env vars (#2813)
Ensures that new test suites won't accidentally break running `go test` when no/incorrect env vars are given. Sets M365 users to bad variables so failures there will show up as well Adds a dep for actions that also have `Test-Suite-Trusted` as a dep --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [x] 💻 CI/Deployment - [x] 🧹 Tech Debt/Cleanup #### Issue(s) * #2373 #### Test Plan - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
8acff1ad93
commit
c6be513ea6
57
.github/workflows/ci.yml
vendored
57
.github/workflows/ci.yml
vendored
@ -230,6 +230,57 @@ jobs:
|
|||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
|
Unit-Test-Suite:
|
||||||
|
needs: [Precheck, Checkout]
|
||||||
|
environment: Testing
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: needs.precheck.outputs.srcfileschanged == 'true'
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: src
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Golang with cache
|
||||||
|
uses: magnetikonline/action-golang-cache@v4
|
||||||
|
with:
|
||||||
|
go-version-file: src/go.mod
|
||||||
|
|
||||||
|
- run: mkdir testlog
|
||||||
|
|
||||||
|
# Install gotestfmt
|
||||||
|
- name: Set up gotestfmt
|
||||||
|
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
|
||||||
|
|
||||||
|
# run the tests
|
||||||
|
- name: Unit Tests
|
||||||
|
env:
|
||||||
|
# Set these to a bad value so we don't accidentally fall back to
|
||||||
|
# something elsewhere.
|
||||||
|
CORSO_M365_TEST_USER_ID: 'foo'
|
||||||
|
CORSO_SECONDARY_M365_TEST_USER_ID: 'foo'
|
||||||
|
CORSO_LOG_FILE: ./src/testlog/testlogging.log
|
||||||
|
LOG_GRAPH_REQUESTS: true
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
go test \
|
||||||
|
-tags testing \
|
||||||
|
-json \
|
||||||
|
-v \
|
||||||
|
-failfast \
|
||||||
|
-p 1 \
|
||||||
|
./... 2>&1 | tee ./testlog/gotest-unit.log | gotestfmt -hide successful-tests
|
||||||
|
|
||||||
|
# Upload the original go test output as an artifact for later review.
|
||||||
|
- name: Upload test log
|
||||||
|
if: failure()
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: unit-test-log
|
||||||
|
path: src/testlog/*
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 14
|
||||||
|
|
||||||
Test-Suite-Fork:
|
Test-Suite-Fork:
|
||||||
needs: [Precheck]
|
needs: [Precheck]
|
||||||
environment: Testing
|
environment: Testing
|
||||||
@ -394,7 +445,7 @@ jobs:
|
|||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
Publish-Binary:
|
Publish-Binary:
|
||||||
needs: [Test-Suite-Trusted, Linting, Website-Linting, SetEnv]
|
needs: [Test-Suite-Trusted, Unit-Test-Suite, Linting, Website-Linting, SetEnv]
|
||||||
environment: ${{ needs.SetEnv.outputs.environment }}
|
environment: ${{ needs.SetEnv.outputs.environment }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
|
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
|
||||||
@ -464,7 +515,7 @@ jobs:
|
|||||||
path: src/dist/corso_windows_amd64_v1/corso.exe
|
path: src/dist/corso_windows_amd64_v1/corso.exe
|
||||||
|
|
||||||
Publish-Image:
|
Publish-Image:
|
||||||
needs: [Test-Suite-Trusted, Linting, Website-Linting, SetEnv]
|
needs: [Test-Suite-Trusted, Unit-Test-Suite, Linting, Website-Linting, SetEnv]
|
||||||
environment: ${{ needs.SetEnv.outputs.environment }}
|
environment: ${{ needs.SetEnv.outputs.environment }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
@ -606,7 +657,7 @@ jobs:
|
|||||||
./corso.exe --version 2>&1 | grep -E "version: ${{ env.CORSO_VERSION }}$"
|
./corso.exe --version 2>&1 | grep -E "version: ${{ env.CORSO_VERSION }}$"
|
||||||
|
|
||||||
Publish-Website-Test:
|
Publish-Website-Test:
|
||||||
needs: [Test-Suite-Trusted, Linting, Website-Linting, SetEnv]
|
needs: [Test-Suite-Trusted, Unit-Test-Suite, Linting, Website-Linting, SetEnv]
|
||||||
environment: ${{ needs.SetEnv.outputs.environment }}
|
environment: ${{ needs.SetEnv.outputs.environment }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user