CI #2268
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: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| schedule: | |
| - cron: 0 0 * * * | |
| permissions: # least privilege; jobs needing OIDC override this | |
| contents: read | |
| jobs: | |
| UnitTests: | |
| strategy: | |
| matrix: | |
| os: [macos-latest, ubuntu-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| permissions: # required for OIDC authentication (coverage upload token) | |
| id-token: write | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Setup .NET 8 | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.x' | |
| - name: Run Unit Tests | |
| # We don't have a good cross-platform way of splitting long lines | |
| run: | | |
| dotnet test dropbox-sdk-dotnet/Dropbox.Api.Unit.Tests --collect:"XPlat Code Coverage" -- 'DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.ExcludeByFile=**/Generated/**/*.cs' | |
| # Coverage upload needs the Codecov token from AWS Secrets Manager, which | |
| # requires OIDC. Fork PRs cannot assume the role (GitHub withholds | |
| # id-token from fork runs), so the coverage-upload steps are gated to | |
| # same-repo runs; unit tests themselves still run everywhere. | |
| - name: Configure AWS credentials (OIDC) | |
| if: matrix.os == 'ubuntu-latest' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) | |
| uses: aws-actions/configure-aws-credentials@v6 | |
| with: | |
| role-to-assume: arn:aws:iam::082972943155:role/oidc-github-dropbox-dropbox-sdk-dotnet-repo | |
| aws-region: us-west-2 | |
| - name: Get Codecov token from AWS Secrets Manager | |
| if: matrix.os == 'ubuntu-latest' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) | |
| uses: aws-actions/aws-secretsmanager-get-secrets@v3 | |
| with: | |
| secret-ids: | | |
| CODECOV_TOKEN,codecov-token-dropbox-sdk-dotnet | |
| parse-json-secrets: false | |
| - name: Publish Coverage | |
| uses: codecov/codecov-action@v7 | |
| if: matrix.os == 'ubuntu-latest' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) | |
| with: | |
| flags: unit | |
| token: ${{ env.CODECOV_TOKEN }} | |
| fail_ci_if_error: true | |
| directory: dropbox-sdk-dotnet/Dropbox.Api.Unit.Tests/TestResults/ | |
| IntegrationTests: | |
| # Integration tests require Dropbox app credentials fetched from AWS Secrets | |
| # Manager via OIDC. Fork PRs cannot assume the role, so skip the job on fork | |
| # PRs (it still runs on same-repo PRs, push to main, and the nightly cron). | |
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository | |
| concurrency: | |
| group: ${{ github.workflow }}-integration-tests | |
| cancel-in-progress: false | |
| queue: max | |
| strategy: | |
| matrix: | |
| os: [macos-latest, ubuntu-latest, windows-latest] | |
| max-parallel: 1 | |
| runs-on: ${{ matrix.os }} | |
| permissions: # required for OIDC authentication | |
| id-token: write | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Setup .NET 8 | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.x' | |
| - name: Configure AWS credentials (OIDC) | |
| uses: aws-actions/configure-aws-credentials@v6 | |
| with: | |
| role-to-assume: arn:aws:iam::082972943155:role/oidc-github-dropbox-dropbox-sdk-dotnet-repo | |
| aws-region: us-west-2 | |
| # The integration credentials are shared by the SDK repositories as a | |
| # single JSON secret. With parse-json-secrets each JSON key is exposed as | |
| # an env var named CREDS_<KEY> (e.g. CREDS_SCOPED_USER_CLIENT_ID). | |
| - name: Get integration credentials from AWS Secrets Manager | |
| uses: aws-actions/aws-secretsmanager-get-secrets@v3 | |
| with: | |
| secret-ids: | | |
| CREDS,api-sdk-integration-test-creds | |
| parse-json-secrets: true | |
| - name: Get Codecov token from AWS Secrets Manager | |
| uses: aws-actions/aws-secretsmanager-get-secrets@v3 | |
| with: | |
| secret-ids: | | |
| CODECOV_TOKEN,codecov-token-dropbox-sdk-dotnet | |
| parse-json-secrets: false | |
| - name: Test Scoped User and Team | |
| env: | |
| DROPBOX_INTEGRATION_appKey: ${{ env.CREDS_SCOPED_USER_CLIENT_ID }} | |
| DROPBOX_INTEGRATION_appSecret: ${{ env.CREDS_SCOPED_USER_CLIENT_SECRET }} | |
| DROPBOX_INTEGRATION_userRefreshToken: ${{ env.CREDS_SCOPED_USER_REFRESH_TOKEN }} | |
| DROPBOX_INTEGRATION_teamAppKey: ${{ env.CREDS_SCOPED_TEAM_CLIENT_ID }} | |
| DROPBOX_INTEGRATION_teamAppSecret: ${{ env.CREDS_SCOPED_TEAM_CLIENT_SECRET }} | |
| DROPBOX_INTEGRATION_teamRefreshToken: ${{ env.CREDS_SCOPED_TEAM_REFRESH_TOKEN }} | |
| run: | | |
| dotnet test dropbox-sdk-dotnet/Dropbox.Api.Integration.Tests --collect:"XPlat Code Coverage" -- 'DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.ExcludeByFile=**/Generated/**/*.cs' | |
| - name: Publish Coverage | |
| uses: codecov/codecov-action@v7 | |
| if: matrix.os == 'ubuntu-latest' | |
| with: | |
| flags: integration | |
| token: ${{ env.CODECOV_TOKEN }} | |
| fail_ci_if_error: true | |
| directory: dropbox-sdk-dotnet/Dropbox.Api.Integration.Tests/TestResults/ | |
| Linter: | |
| strategy: | |
| matrix: | |
| os: [macos-latest, ubuntu-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Setup .NET 8 | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '8.x' | |
| - name: Run Linter | |
| run: | | |
| dotnet restore dropbox-sdk-dotnet/ | |
| dotnet format dropbox-sdk-dotnet/ --verify-no-changes --severity warn |