Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/actions/test_ruby_gem_uploads/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ runs:
env:
TRUNK_QUARANTINE_QUERY_FAILURE_EXIT: "true"
TRUNK_ORG_URL_SLUG: fake-org
TRUNK_API_TOKEN: fake-token
# A fake v2 API key: an organization token would leave the gem off.
# trunk-ignore(checkov/CKV_SECRET_6)
TRUNK_API_TOKEN: trunk_v2_fake-token
TRUNK_TEST_COLLECTION_ID: tc_fake
TRUNK_QUARANTINED_TESTS_DISK_CACHE_TTL_SECS: "0"
TRUNK_API_CLIENT_RETRY_COUNT: "0"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ jobs:
target/${{ matrix.platform.target }}/release/trunk-analytics-cli upload \
--junit-paths ${{ github.workspace }}/target/**/*junit.xml \
--org-url-slug trunk-staging-org \
--token ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} \
--token ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }} \
--test-process-exit-code ${{ steps.extract.outputs.test-step-outcome }} \
--test-collection-id 2tYJWMu7 \
--variant ${{ matrix.platform.target }}
Expand All @@ -286,7 +286,7 @@ jobs:
target/${{ matrix.platform.target }}/release/trunk-analytics-cli upload \
--junit-paths ${{ github.workspace }}/target/**/*junit.xml \
--org-url-slug trunk-staging-org \
--token ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} \
--token ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }} \
--test-process-exit-code ${{ steps.extract.outputs.test-step-outcome }} \
--test-collection-id Gtnr7BWl \
--variant ${{ matrix.platform.target }}
Expand All @@ -302,7 +302,7 @@ jobs:
target/${{ matrix.platform.target }}/release/trunk-analytics-cli upload \
--junit-paths ${{ github.workspace }}/target/**/*junit.xml \
--org-url-slug trunk \
--token ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }} \
--token ${{ secrets.TRUNK_PROD_API_V2_TOKEN }} \
--test-collection-id EWhNPVic \
--variant ${{ matrix.platform.target }}
# analytics-cli-pr: https://app.trunk.io/trunk/flaky-tests/collections/EWhNPVic/monitors
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pyo3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
./target/debug/trunk-analytics-cli upload \
--junit-paths context-py/junit.xml \
--org-url-slug trunk-staging-org \
--token ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} \
--token ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }} \
--test-collection-id 6E6WINjl \
--variant ${{ matrix.platform.target }}
env:
Expand All @@ -192,7 +192,7 @@ jobs:
./target/debug/trunk-analytics-cli upload \
--junit-paths context-py/junit.xml \
--org-url-slug trunk \
--token ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }} \
--token ${{ secrets.TRUNK_PROD_API_V2_TOKEN }} \
--test-collection-id 68IdP3pq \
--variant ${{ matrix.platform.target }}
env:
Expand Down Expand Up @@ -225,7 +225,7 @@ jobs:
./target/debug/trunk-analytics-cli upload \
--junit-paths context-py/junit.xml \
--org-url-slug trunk-staging-org \
--token ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} \
--token ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }} \
--test-collection-id 6E6WINjl \
--variant ${{ matrix.platform.target }}
env:
Expand All @@ -238,7 +238,7 @@ jobs:
./target/debug/trunk-analytics-cli upload \
--junit-paths context-py/junit.xml \
--org-url-slug trunk \
--token ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }} \
--token ${{ secrets.TRUNK_PROD_API_V2_TOKEN }} \
--test-collection-id 68IdP3pq \
--variant ${{ matrix.platform.target }}
env:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ jobs:
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static binfmt-support \
sudo apt-get install -y qemu-user-binfmt \
libc6-${{ matrix.type.qemu-deb-arch }}-cross libgcc-s1-${{ matrix.type.qemu-deb-arch }}-cross
echo "QEMU_LD_PREFIX=/usr/${{ matrix.type.qemu-triple }}" >> "$GITHUB_ENV"
chmod +x trunk-analytics-cli/trunk-analytics-cli
Expand All @@ -264,16 +264,16 @@ jobs:
uses: ./.github/actions/perform_smoke_test
with:
cli-binary-location: trunk-analytics-cli/trunk-analytics-cli
staging-api-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
production-api-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
staging-api-token: ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }}
production-api-token: ${{ secrets.TRUNK_PROD_API_V2_TOKEN }}

- name: Run Smoke Tests (Windows)
if: ${{ matrix.type.name == 'windows' }}
uses: ./.github/actions/perform_smoke_test
with:
cli-binary-location: trunk-analytics-cli/trunk-analytics-cli.exe
staging-api-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
production-api-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
staging-api-token: ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }}
production-api-token: ${{ secrets.TRUNK_PROD_API_V2_TOKEN }}

tag_and_release:
name: Tag and Release [ ${{ github.event.inputs.release_tag || inputs.release_tag }} ]
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release_ruby_gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: ${{ matrix.ruby-version }}
trunk-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
trunk-token: ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }}
trunk-public-api-address: https://api.trunk-staging.io
trunk-org-slug: trunk-staging-org
test-collection-id: T5yKSn9h
Expand All @@ -147,7 +147,7 @@ jobs:
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: ${{ matrix.ruby-version }}
trunk-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
trunk-token: ${{ secrets.TRUNK_PROD_API_V2_TOKEN }}
trunk-public-api-address: https://api.trunk.io
trunk-org-slug: trunk
test-collection-id: BiBP2neA
Expand Down Expand Up @@ -178,7 +178,7 @@ jobs:
with:
alpine: "true"
ruby-version: ${{ matrix.ruby-version }}
trunk-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
trunk-token: ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }}
trunk-public-api-address: https://api.trunk-staging.io
trunk-org-slug: trunk-staging-org
test-collection-id: T5yKSn9h
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
run: |
./target/debug/trunk-analytics-cli upload \
--org-url-slug trunk-staging-org \
--token ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} \
--token ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }} \
--test-reports ./upload_bundle/trunk_output.bin \
--test-collection-id T5yKSn9h
env:
Expand All @@ -79,7 +79,7 @@ jobs:
run: |
./target/debug/trunk-analytics-cli upload \
--org-url-slug trunk \
--token ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }} \
--token ${{ secrets.TRUNK_PROD_API_V2_TOKEN }} \
--test-reports ./upload_bundle/trunk_output.bin \
--test-collection-id BiBP2neA
env:
Expand All @@ -90,7 +90,7 @@ jobs:
run: |
./target/debug/trunk-analytics-cli upload \
--org-url-slug trunk-staging-org \
--token ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} \
--token ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }} \
--test-reports ./upload_bundle/trunk_output.bin \
--test-collection-id z2dzjLHm
env:
Expand All @@ -101,7 +101,7 @@ jobs:
run: |
./target/debug/trunk-analytics-cli upload \
--org-url-slug trunk \
--token ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }} \
--token ${{ secrets.TRUNK_PROD_API_V2_TOKEN }} \
--test-reports ./upload_bundle/trunk_output.bin \
--test-collection-id 4B2wfoEU
env:
Expand Down Expand Up @@ -199,7 +199,7 @@ jobs:
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: "3.4"
trunk-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
trunk-token: ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }}
trunk-public-api-address: https://api.trunk-staging.io
trunk-org-slug: trunk-staging-org
test-collection-id: T5yKSn9h
Expand All @@ -211,7 +211,7 @@ jobs:
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: "3.4"
trunk-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
trunk-token: ${{ secrets.TRUNK_PROD_API_V2_TOKEN }}
trunk-public-api-address: https://api.trunk.io
trunk-org-slug: trunk
test-collection-id: BiBP2neA
Expand All @@ -223,7 +223,7 @@ jobs:
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: "3.4"
trunk-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
trunk-token: ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }}
trunk-public-api-address: https://api.trunk-staging.io
trunk-org-slug: trunk-staging-org
test-collection-id: z2dzjLHm
Expand All @@ -235,7 +235,7 @@ jobs:
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: "3.4"
trunk-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
trunk-token: ${{ secrets.TRUNK_PROD_API_V2_TOKEN }}
trunk-public-api-address: https://api.trunk.io
trunk-org-slug: trunk
test-collection-id: 4B2wfoEU
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/smoke_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ jobs:
uses: ./.github/actions/perform_smoke_test
with:
cli-binary-location: ${{ matrix.platform.binary-name }}
staging-api-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
production-api-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
staging-api-token: ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }}
production-api-token: ${{ secrets.TRUNK_PROD_API_V2_TOKEN }}
environment-type: ${{ (github.event.action == 'production-release' && 'production') || (github.event.action == 'staging-release' && 'staging') || 'both' }}

download_ruby_gem:
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: "3.4"
trunk-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
trunk-token: ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }}
trunk-public-api-address: https://api.trunk-staging.io
trunk-org-slug: trunk-staging-org
# analytics-cli-ruby-gem: https://app.trunk-staging.io/trunk-staging-org/flaky-tests/collections/T5yKSn9h/monitors
Expand All @@ -197,7 +197,7 @@ jobs:
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: "3.4"
trunk-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
trunk-token: ${{ secrets.TRUNK_PROD_API_V2_TOKEN }}
trunk-public-api-address: https://api.trunk.io
trunk-org-slug: trunk
# analytics-cli-ruby-gem: https://app.trunk.io/trunk/flaky-tests/collections/BiBP2neA/monitors
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/smoke_test_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,17 @@ jobs:
uses: ./.github/actions/perform_smoke_test
with:
cli-binary-location: ${{ matrix.platform.binary-name }}
staging-api-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
production-api-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
staging-api-token: ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }}
production-api-token: ${{ secrets.TRUNK_PROD_API_V2_TOKEN }}
environment-type: ${{ (github.event.action == 'production-release' && 'production') || (github.event.action == 'staging-release' && 'staging') || 'both' }}
test-variants: "true"

- name: Run Smoke Tests With Gitlab
uses: ./.github/actions/perform_gitlab_smoke_test
with:
cli-binary-location: ${{ matrix.platform.binary-name }}
staging-api-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
production-api-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
staging-api-token: ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }}
production-api-token: ${{ secrets.TRUNK_PROD_API_V2_TOKEN }}
environment-type: ${{ (github.event.action == 'production-release' && 'production') || (github.event.action == 'staging-release' && 'staging') || 'both' }}

build_ruby_gem:
Expand Down Expand Up @@ -223,7 +223,7 @@ jobs:
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: "4.0"
trunk-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
trunk-token: ${{ secrets.TRUNK_STAGING_API_V2_TOKEN }}
trunk-public-api-address: https://api.trunk-staging.io
trunk-org-slug: trunk-staging-org
# analytics-cli-ruby-gem: https://app.trunk-staging.io/trunk-staging-org/flaky-tests/collections/T5yKSn9h/monitors
Expand Down Expand Up @@ -253,7 +253,7 @@ jobs:
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: "4.0"
trunk-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
trunk-token: ${{ secrets.TRUNK_PROD_API_V2_TOKEN }}
trunk-public-api-address: https://api.trunk.io
trunk-org-slug: trunk
# analytics-cli-ruby-gem: https://app.trunk.io/trunk/flaky-tests/collections/BiBP2neA/monitors
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ cargo build
./target/debug/trunk-analytics-cli upload --org-url-slug=trunk-io --token=${API_TOKEN} --test-collection-id=${TEST_COLLECTION_ID} --junit-paths=junit.xml
```

`API_TOKEN` is a v2 API key (`trunk_v2_...`) or a Trunk JWT, such as `trunk flakytests upload` passes; the CLI refuses an organization token before any call. See [Credentials](README.md#credentials).

You can generate sample junit files by running

```bash
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
Rust CLI for uploading test output to [Trunk Flaky Tests][flaky-tests]. Please follow the instructions to [start uploading][app] or check out our [docs].
This is downloaded automatically using the [Trunk launcher][launcher] and when using the [analytics-uploader GitHub Action][uploader].

## Credentials

`--token` / `TRUNK_API_TOKEN` takes one of two credentials. The CLI reads which one before it calls Trunk:

- **A v2 API key** (`trunk_v2_...`). Create one at https://app.trunk.io/settings/developer/api-tokens, and give it the **Upload test results** (`upload_test_results`) permission. The CLI sends it as `Authorization: Bearer`.
- **A Trunk JWT**. The CLI sends it on `x-trunk-token`. With a key stored by `trunk auth api-key set`, `trunk flakytests upload` exchanges it for a JWT just before the upload and passes that in `TRUNK_API_TOKEN`, while `trunk flakytests test` passes the key itself. A JWT lasts at most 15 minutes, and the one `trunk flakytests upload` passes can have about a minute left, so use a JWT only for the upload itself: a long `trunk-analytics-cli test` run, or a test-runner plugin that looks up quarantined tests early and uploads at the end, can outlive it, so give those a v2 API key. When Trunk refuses an expired JWT, the CLI says so; it does not refresh it.

analytics-cli 1.0.0 refuses any other token, the organization token included, before it calls Trunk. Pin analytics-cli 0.17.x to keep using the organization token until December 1, 2027.

If Trunk answers `403` because the key lacks the Upload test results permission, edit the key on the API Keys screen to add it.

`--allow-forked-pr-uploads` uploads with no token, only from a GitHub Actions run of a pull request from a fork: the CLI swaps the job's `GITHUB_TOKEN` for a Trunk login.

## Development

For more information about how to build and run the Rust CLI, please see [CONTRIBUTING.md][contributing].
Loading
Loading