2022-03-22 11:03:15 -04:00
|
|
|
name: Unit Tests
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2022-10-18 10:17:41 -04:00
|
|
|
- "release/**"
|
2022-09-03 11:47:47 -04:00
|
|
|
paths:
|
|
|
|
- "**.go"
|
2022-10-14 04:27:49 -04:00
|
|
|
- "**/go.mod"
|
|
|
|
- "**/go.sum"
|
2023-01-24 05:39:26 -05:00
|
|
|
- "**/testdata/**"
|
2023-02-14 14:01:00 -05:00
|
|
|
- ".github/workflows/test-unittest.yml"
|
2022-03-22 11:03:15 -04:00
|
|
|
pull_request:
|
2022-09-03 11:47:47 -04:00
|
|
|
paths:
|
2023-01-31 05:21:32 -05:00
|
|
|
- "cli/internal/helm/**"
|
2022-09-03 11:47:47 -04:00
|
|
|
- "**.go"
|
2022-10-14 04:27:49 -04:00
|
|
|
- "**/go.mod"
|
|
|
|
- "**/go.sum"
|
2023-01-24 05:39:26 -05:00
|
|
|
- "**/testdata/**"
|
2023-02-14 14:01:00 -05:00
|
|
|
- ".github/workflows/test-unittest.yml"
|
2022-03-22 11:03:15 -04:00
|
|
|
|
|
|
|
jobs:
|
2023-05-19 10:18:59 -04:00
|
|
|
test-unittest:
|
2023-11-03 06:59:19 -04:00
|
|
|
runs-on: [arc-runner-set]
|
2023-08-23 12:52:46 -04:00
|
|
|
permissions:
|
|
|
|
id-token: write
|
|
|
|
contents: read
|
|
|
|
pull-requests: write
|
2022-03-22 11:03:15 -04:00
|
|
|
steps:
|
2022-07-20 04:48:01 -04:00
|
|
|
- name: Checkout
|
2023-10-11 07:49:50 -04:00
|
|
|
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
2022-09-19 04:59:46 -04:00
|
|
|
with:
|
2023-10-24 08:31:13 -04:00
|
|
|
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
|
2023-08-23 12:52:46 -04:00
|
|
|
fetch-depth: 0
|
|
|
|
|
2023-11-03 06:59:19 -04:00
|
|
|
- name: Setup bazel
|
|
|
|
uses: ./.github/actions/setup_bazel_nix
|
|
|
|
with:
|
|
|
|
useCache: "rbe"
|
|
|
|
rbePlatform: "ubuntu-22.04"
|
|
|
|
buildBuddyApiKey: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
|
|
|
|
|
2023-08-23 12:52:46 -04:00
|
|
|
- name: Install AWS cli
|
|
|
|
run: |
|
|
|
|
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
|
|
|
|
unzip awscliv2.zip
|
|
|
|
sudo ./aws/install
|
|
|
|
rm -rf awscliv2.zip aws
|
|
|
|
|
|
|
|
- name: Login to AWS (IAM role)
|
2023-10-26 02:18:37 -04:00
|
|
|
uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
|
2023-08-23 12:52:46 -04:00
|
|
|
with:
|
|
|
|
role-to-assume: arn:aws:iam::795746500882:role/GithubActionGocoverage
|
|
|
|
aws-region: eu-central-1
|
2022-03-22 11:03:15 -04:00
|
|
|
|
2022-06-30 07:26:21 -04:00
|
|
|
- name: Unit Tests
|
2022-10-31 14:25:02 -04:00
|
|
|
env:
|
|
|
|
TMPDIR: ${{ runner.temp }}
|
2023-11-03 06:59:19 -04:00
|
|
|
run: bazel test //... --test_output=errors --config=nostamp --remote_download_minimal
|
2023-08-23 12:52:46 -04:00
|
|
|
|
|
|
|
- name: Coverage
|
|
|
|
id: coverage
|
|
|
|
run: |
|
2023-11-03 06:59:19 -04:00
|
|
|
bazel run //bazel/ci:gocoverage_diff --config=nostamp
|
2023-08-23 12:52:46 -04:00
|
|
|
lines=$(wc -l < coverage_diff.md)
|
|
|
|
uploadable=$([[ ${lines} -gt 3 ]] && echo "true" || echo "false")
|
|
|
|
echo "uploadable=$uploadable" | tee -a "$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
- name: Comment coverage
|
|
|
|
if: steps.coverage.outputs.uploadable == 'true' && github.event_name == 'pull_request'
|
|
|
|
uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # v2.8.0
|
|
|
|
with:
|
|
|
|
header: coverage
|
|
|
|
path: coverage_diff.md
|
2023-09-26 04:18:41 -04:00
|
|
|
recreate: true
|
2023-08-23 12:52:46 -04:00
|
|
|
|
|
|
|
- name: Upload coverage
|
|
|
|
if: github.ref_name == 'main'
|
|
|
|
run: |
|
|
|
|
cat coverage_result.json
|
|
|
|
aws s3 cp coverage_result.json s3://constellation-ci/gocoverage/coverage_main.json
|
|
|
|
echo "coverage uploaded to s3://constellation-ci/gocoverage/coverage_main.json"
|