Compaction speedup: Reuse c1file for compaction steps. #2036
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ci | |
| on: pull_request | |
| jobs: | |
| go-lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: 1.25.2 | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Run linters | |
| uses: golangci/golangci-lint-action@v8 | |
| with: | |
| skip-cache: true | |
| version: latest | |
| args: --timeout=3m | |
| go-test: | |
| strategy: | |
| matrix: | |
| go-version: [1.25.2] | |
| platform: [ubuntu-latest, windows-latest] | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - name: Install Go | |
| if: success() | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: go tests | |
| run: go test -tags=baton_lambda_support -v -covermode=count -json ./... > test.json | |
| - name: Print go test results | |
| if: always() | |
| run: cat test.json | |
| - name: annotate go tests | |
| if: always() | |
| uses: guyarb/[email protected] | |
| with: | |
| test-results: test.json | |
| buf-lint-and-breaking-change-detection: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: bufbuild/buf-setup-action@v1 | |
| with: | |
| version: '1.50.0' | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Lint | |
| uses: bufbuild/buf-lint-action@v1 | |
| - name: Breaking change detection against `main` | |
| uses: bufbuild/buf-breaking-action@v1 | |
| with: | |
| against: 'https://github.com/conductorone/baton-sdk.git#branch=main' | |
| baton-demo-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| path: baton-sdk | |
| - name: Install Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: baton-sdk/go.mod | |
| - name: Checkout baton-demo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: conductorone/baton-demo | |
| path: baton-demo | |
| ref: main | |
| - name: Replace baton-sdk with local version | |
| run: | | |
| cd baton-demo | |
| go mod edit -replace github.com/conductorone/baton-sdk=../baton-sdk | |
| go mod tidy && go mod vendor | |
| - name: Build baton-demo | |
| run: | | |
| cd baton-demo | |
| go build ./cmd/baton-demo | |
| - name: Initialize database | |
| run: ./baton-demo/baton-demo --init-db | |
| - name: Test grant/revoke | |
| uses: ConductorOne/github-workflows/actions/sync-test@v2 | |
| with: | |
| connector: ./baton-demo/baton-demo | |
| baton-entitlement: 'group:group-0000001:member' | |
| baton-principal: 'user-0000000' | |
| baton-principal-type: 'user' | |
| - name: Test create account | |
| uses: ConductorOne/github-workflows/actions/account-provisioning@v3 | |
| with: | |
| connector: ./baton-demo/baton-demo | |
| account-email: [email protected] | |
| account-login: testuser1 | |
| account-profile: '{"username": "testuser1", "email": "[email protected]", "firstName": "test", "lastName": "user1"}' | |
| - name: Test rotate credentials | |
| run: ./baton-demo/baton-demo --rotate-credentials=user-0000000 --rotate-credentials-type=user | |
| - name: Test targeted resources | |
| run: | | |
| set -euo pipefail | |
| cd baton-demo | |
| # Clean previous sync file if present | |
| rm -f sync.c1z | |
| # Run the targeted sync | |
| ./baton-demo \ | |
| --sync-resources='"bid:r:group/group-0000000","bid:r:group/group-0000001","bid:r:role/role-0000000"' | |
| # Dump resources as JSON | |
| baton resources --output-format=json > resources.json | |
| cat resources.json | |
| # Validate resource count | |
| jq -e '(.resources | length) == 3' resources.json > /dev/null | |
| # Build actual + expected sorted arrays | |
| actual_sorted="$(jq -r ' | |
| [ .resources[] | |
| | "bid:r:\(.resourceType.id)/\(.resource.id.resource)" | |
| ] | sort | @json | |
| ' resources.json)" | |
| expected_sorted="$(jq -r -n ' | |
| ["bid:r:group/group-0000000", | |
| "bid:r:group/group-0000001", | |
| "bid:r:role/role-0000000"] | |
| | sort | @json | |
| ')" | |
| # Compare | |
| if [[ "$actual_sorted" != "$expected_sorted" ]]; then | |
| echo "Resource set mismatch" | |
| echo "Expected: $expected_sorted" | |
| echo "Actual: $actual_sorted" | |
| echo "Diff:" | |
| diff <(echo "$actual_sorted" | jq -r '.[]') <(echo "$expected_sorted" | jq -r '.[]') || true | |
| exit 1 | |
| else | |
| echo "Resource set matches expected" | |
| fi | |
| - name: Test sync by resource type | |
| run: | | |
| set -euo pipefail | |
| cd baton-demo | |
| # Clean previous sync file if present | |
| rm -f sync.c1z | |
| # Run targeted sync for resource type "group" | |
| ./baton-demo --sync-resource-types group | |
| # Dump resources as JSON | |
| baton resources --output-format=json > resources.json | |
| cat resources.json | |
| # Validate resource count (should be 4) | |
| jq -e '(.resources | length) == 4' resources.json > /dev/null | |
| # Validate all resources are type "group" | |
| jq -e '(.resources | map(select(.resourceType.id == "group")) | length) == (.resources | length)' resources.json > /dev/null | |
| # Build actual and expected sorted arrays | |
| actual_sorted="$(jq -r ' | |
| [ .resources[] | |
| | "bid:r:\(.resourceType.id)/\(.resource.id.resource)" | |
| ] | sort | @json | |
| ' resources.json)" | |
| expected_sorted="$(jq -r -n ' | |
| ["bid:r:group/group-0000000", | |
| "bid:r:group/group-0000001", | |
| "bid:r:group/group-0000002", | |
| "bid:r:group/group-everyone"] | |
| | sort | @json | |
| ')" | |
| # Compare | |
| if [[ "$actual_sorted" != "$expected_sorted" ]]; then | |
| echo "Resource set mismatch" | |
| echo "Expected: $expected_sorted" | |
| echo "Actual: $actual_sorted" | |
| echo "Diff:" | |
| diff <(echo "$actual_sorted" | jq -r '.[]') <(echo "$expected_sorted" | jq -r '.[]') || true | |
| exit 1 | |
| else | |
| echo "Resource set matches expected" | |
| fi | |
| - name: Test with both --sync-resource-types and --sync-resources | |
| run: | | |
| set -euo pipefail | |
| cd baton-demo | |
| rm -f sync.c1z | |
| # Run with BOTH filters: type=group AND a mixed list (groups + role + user) | |
| ./baton-demo \ | |
| --sync-resource-types group \ | |
| --sync-resources='"bid:r:group/group-0000000","bid:r:group/group-0000002","bid:r:role/role-0000001","bid:r:user/user-0000003"' | |
| # Dump resources to JSON | |
| baton resources --output-format=json > resources.json | |
| cat resources.json | |
| # Validate the result is exactly the intersection: 2 groups (0000000, 0000002) | |
| jq -e '(.resources | length) == 2' resources.json > /dev/null | |
| jq -e '(.resources | map(select(.resourceType.id == "group")) | length) == (.resources | length)' resources.json > /dev/null | |
| # Build actual and expected sets (order-independent) | |
| actual_sorted="$(jq -r ' | |
| [ .resources[] | |
| | "bid:r:\(.resourceType.id)/\(.resource.id.resource)" | |
| ] | sort | @json | |
| ' resources.json)" | |
| expected_sorted="$(jq -r -n ' | |
| ["bid:r:group/group-0000000", | |
| "bid:r:group/group-0000002"] | |
| | sort | @json | |
| ')" | |
| # Compare | |
| if [[ "$actual_sorted" != "$expected_sorted" ]]; then | |
| echo "Resource set mismatch" | |
| echo "Expected: $expected_sorted" | |
| echo "Actual: $actual_sorted" | |
| echo "Diff:" | |
| diff <(echo "$actual_sorted" | jq -r '.[]') <(echo "$expected_sorted" | jq -r '.[]') || true | |
| exit 1 | |
| else | |
| echo "Resource set matches expected (intersection)" | |
| fi |