diff --git a/.github/workflows/data-file-change.yml b/.github/workflows/data-file-change.yml index 8fadf2a5b..22eaa8f3d 100644 --- a/.github/workflows/data-file-change.yml +++ b/.github/workflows/data-file-change.yml @@ -23,7 +23,4 @@ jobs: org-name: ${{ github.event.repository.owner.login }} dryrun: ${{ inputs.dryrun || false }} common-ci-ref: ${{ inputs.common-ci-ref || '' }} - secrets: - token: ${{ secrets.ACCESS_TOKEN }} - data-key: ${{ secrets.DEVICE_DETECTION_KEY }} - data-url: ${{ secrets.DEVICE_DETECTION_URL }} + secrets: inherit diff --git a/.github/workflows/example-assets-update.yml b/.github/workflows/example-assets-update.yml index aff060ff8..0499b12f0 100644 --- a/.github/workflows/example-assets-update.yml +++ b/.github/workflows/example-assets-update.yml @@ -22,5 +22,4 @@ jobs: with: repo-name: ${{ github.event.repository.name }} common-ci-ref: ${{ inputs.common-ci-ref || '' }} - secrets: - token: ${{ secrets.ACCESS_TOKEN }} + secrets: inherit diff --git a/.github/workflows/monthly-copyright-update.yml b/.github/workflows/monthly-copyright-update.yml index fdc6d3383..dde0e98af 100644 --- a/.github/workflows/monthly-copyright-update.yml +++ b/.github/workflows/monthly-copyright-update.yml @@ -17,5 +17,4 @@ jobs: repo-name: ${{ github.event.repository.name }} org-name: ${{ github.event.repository.owner.login }} dryrun: ${{ inputs.dryrun || false }} - secrets: - token: ${{ secrets.ACCESS_TOKEN }} + secrets: inherit diff --git a/.github/workflows/nightly-pipeline.yml b/.github/workflows/nightly-pipeline.yml index ce793b713..8f32fa3ef 100644 --- a/.github/workflows/nightly-pipeline.yml +++ b/.github/workflows/nightly-pipeline.yml @@ -21,10 +21,7 @@ jobs: org-name: ${{ github.event.repository.owner.login }} dryrun: ${{ inputs.dryrun || false }} common-ci-ref: ${{ inputs.common-ci-ref || '' }} - secrets: - token: ${{ secrets.ACCESS_TOKEN }} - data-key: ${{ secrets.DEVICE_DETECTION_KEY }} - data-url: ${{ secrets.DEVICE_DETECTION_URL }} + secrets: inherit PackageUpdate: name: Nightly Package Update @@ -34,8 +31,7 @@ jobs: org-name: ${{ github.event.repository.owner.login }} dryrun: ${{ inputs.dryrun || false }} common-ci-ref: ${{ inputs.common-ci-ref || '' }} - secrets: - token: ${{ secrets.ACCESS_TOKEN }} + secrets: inherit SubmoduleUpdate: name: Nightly Submodule Update @@ -45,8 +41,7 @@ jobs: org-name: ${{ github.event.repository.owner.login }} dryrun: ${{ inputs.dryrun || false }} common-ci-ref: ${{ inputs.common-ci-ref || '' }} - secrets: - token: ${{ secrets.ACCESS_TOKEN }} + secrets: inherit PullRequests: if: ${{ !cancelled() }} @@ -59,13 +54,7 @@ jobs: dryrun: ${{ inputs.dryrun || false }} common-ci-ref: ${{ inputs.common-ci-ref || '' }} cache-assets: true - secrets: - token: ${{ secrets.ACCESS_TOKEN }} - DeviceDetection: ${{ secrets.DEVICE_DETECTION_KEY }} - DeviceDetectionUrl: ${{ secrets.DEVICE_DETECTION_URL }} - IpIntelligence: ${{ secrets.IP_INTELLIGENCE_KEY }} - IpIntelligenceUrl: ${{ secrets.IPI_DATA_FILE_URL }} - TestResourceKey: ${{ secrets._51DEGREES_RESOURCE_KEY_BESPOKE }} + secrets: inherit Publish: if: ${{ !cancelled() }} @@ -78,20 +67,4 @@ jobs: dryrun: ${{ inputs.dryrun || false }} common-ci-ref: ${{ inputs.common-ci-ref || '' }} cache-assets: true - secrets: - token: ${{ secrets.ACCESS_TOKEN }} - DeviceDetection: ${{ secrets.DEVICE_DETECTION_KEY }} - DeviceDetectionUrl: ${{ secrets.DEVICE_DETECTION_URL }} - IpIntelligence: ${{ secrets.IP_INTELLIGENCE_KEY }} - IpIntelligenceUrl: ${{ secrets.IPI_DATA_FILE_URL }} - TestResourceKey: ${{ secrets._51DEGREES_RESOURCE_KEY_BESPOKE }} - MavenSettings: ${{ secrets.MAVEN_SETTINGS }} - JavaGpgKeyPassphrase: ${{ secrets.JAVA_GPG_KEY_PASSPHRASE }} - JavaPGP: ${{ secrets.JAVA_KEY_PGP_FILE }} - CodeSigningKeyVaultName: ${{ secrets.CODE_SIGNING_KEY_VAULT_NAME }} - CodeSigningKeyVaultUrl: ${{ secrets.CODE_SIGNING_KEY_VAULT_URL }} - CodeSigningKeyVaultClientId: ${{ secrets.CODE_SIGNING_KEY_VAULT_CLIENT_ID }} - CodeSigningKeyVaultTenantId: ${{ secrets.CODE_SIGNING_KEY_VAULT_TENANT_ID }} - CodeSigningKeyVaultClientSecret: ${{ secrets.CODE_SIGNING_KEY_VAULT_CLIENT_SECRET }} - CodeSigningKeyVaultCertificateName: ${{ secrets.CODE_SIGNING_KEY_VAULT_CERTIFICATE_NAME }} - CodeSigningKeyVaultCertificateData: ${{ secrets.CODE_SIGNING_KEY_VAULT_CERTIFICATE_DATA }} + secrets: inherit diff --git a/.github/workflows/package-update.yml b/.github/workflows/package-update.yml index 37cd28ee4..3dacbc3fe 100644 --- a/.github/workflows/package-update.yml +++ b/.github/workflows/package-update.yml @@ -19,5 +19,4 @@ jobs: org-name: ${{ github.event.repository.owner.login }} dryrun: ${{ inputs.dryrun || false }} common-ci-ref: ${{ inputs.common-ci-ref || '' }} - secrets: - token: ${{ secrets.ACCESS_TOKEN }} + secrets: inherit diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7989697c2..9e0290371 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,20 +20,4 @@ jobs: dryrun: ${{ inputs.dryrun || false }} common-ci-ref: ${{ inputs.common-ci-ref || '' }} cache-assets: true - secrets: - token: ${{ secrets.ACCESS_TOKEN }} - DeviceDetection: ${{ secrets.DEVICE_DETECTION_KEY }} - DeviceDetectionUrl: ${{ secrets.DEVICE_DETECTION_URL }} - IpIntelligence: ${{ secrets.IP_INTELLIGENCE_KEY }} - IpIntelligenceUrl: ${{ secrets.IPI_DATA_FILE_URL }} - TestResourceKey: ${{ secrets._51DEGREES_RESOURCE_KEY_BESPOKE }} - MavenSettings: ${{ secrets.MAVEN_SETTINGS }} - JavaGpgKeyPassphrase: ${{ secrets.JAVA_GPG_KEY_PASSPHRASE }} - JavaPGP: ${{ secrets.JAVA_KEY_PGP_FILE }} - CodeSigningKeyVaultName: ${{ secrets.CODE_SIGNING_KEY_VAULT_NAME }} - CodeSigningKeyVaultUrl: ${{ secrets.CODE_SIGNING_KEY_VAULT_URL }} - CodeSigningKeyVaultClientId: ${{ secrets.CODE_SIGNING_KEY_VAULT_CLIENT_ID }} - CodeSigningKeyVaultTenantId: ${{ secrets.CODE_SIGNING_KEY_VAULT_TENANT_ID }} - CodeSigningKeyVaultClientSecret: ${{ secrets.CODE_SIGNING_KEY_VAULT_CLIENT_SECRET }} - CodeSigningKeyVaultCertificateName: ${{ secrets.CODE_SIGNING_KEY_VAULT_CERTIFICATE_NAME }} - CodeSigningKeyVaultCertificateData: ${{ secrets.CODE_SIGNING_KEY_VAULT_CERTIFICATE_DATA }} + secrets: inherit diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index c1fda910b..33d5c1822 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -20,10 +20,4 @@ jobs: dryrun: ${{ inputs.dryrun || false }} common-ci-ref: ${{ inputs.common-ci-ref || '' }} cache-assets: true - secrets: - token: ${{ secrets.ACCESS_TOKEN }} - DeviceDetection: ${{ secrets.DEVICE_DETECTION_KEY }} - DeviceDetectionUrl: ${{ secrets.DEVICE_DETECTION_URL }} - IpIntelligence: ${{ secrets.IP_INTELLIGENCE_KEY }} - IpIntelligenceUrl: ${{ secrets.IPI_DATA_FILE_URL }} - TestResourceKey: ${{ secrets._51DEGREES_RESOURCE_KEY_BESPOKE }} + secrets: inherit diff --git a/.github/workflows/submodule-update.yml b/.github/workflows/submodule-update.yml index 7bf3291c8..d3b64cce2 100644 --- a/.github/workflows/submodule-update.yml +++ b/.github/workflows/submodule-update.yml @@ -19,5 +19,4 @@ jobs: org-name: ${{ github.event.repository.owner.login }} dryrun: ${{ inputs.dryrun || false }} common-ci-ref: ${{ inputs.common-ci-ref || '' }} - secrets: - token: ${{ secrets.ACCESS_TOKEN }} + secrets: inherit diff --git a/ci/README.md b/ci/README.md index b00a5034a..13a9d492b 100644 --- a/ci/README.md +++ b/ci/README.md @@ -38,21 +38,23 @@ repositories used to do for one package tree each. ## Secrets +The workflows pass the secrets to the shared workflows with +`secrets: inherit`, and each job exports the secrets it uses under their own +names. The signing secrets reach only the job that builds the packages, and +`MAVEN_SETTINGS` only the job that publishes. + Required: -- `ACCESS_TOKEN`: GitHub +- `CI_ACCESS_TOKEN`: GitHub [access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#about-personal-access-tokens) for cloning repositories and creating pull requests. To run the on-premise tests: -- `DEVICE_DETECTION_KEY`: [license key](https://51degrees.com/pricing?utm_source=github&utm_medium=readme&utm_campaign=51degrees-java&utm_content=ci-readme.md&utm_term=secrets) - for the Device Detection TAC data file and the data file update example. -- `IP_INTELLIGENCE_KEY`: license key for the IP Intelligence Enterprise data - file. -- `IPI_DATA_FILE_URL`: URL of the IP Intelligence Enterprise data file. The - IP Intelligence examples and benchmark are skipped without it. -- `DEVICE_DETECTION_URL` (optional): URL of the Device Detection TAC data file. +- `LICENSE_KEY_V4TAC_IPIV4ENTERPRISE`: [license key](https://51degrees.com/pricing?utm_source=github&utm_medium=readme&utm_campaign=51degrees-java&utm_content=ci-readme.md&utm_term=secrets) + for the Device Detection TAC and IP Intelligence Enterprise data files and + the data file update example, which common-ci gives the steps that need it + as `_51DEGREES_LICENSE_KEY`. To run the cloud tests: diff --git a/ci/build-package.ps1 b/ci/build-package.ps1 index 75464f09f..71fc96c3e 100644 --- a/ci/build-package.ps1 +++ b/ci/build-package.ps1 @@ -1,7 +1,6 @@ param( [Parameter(Mandatory)][string]$RepoName, [Parameter(Mandatory)][string]$Version, - [Parameter(Mandatory)][Hashtable]$Keys, [string]$Name ) $ErrorActionPreference = "Stop" @@ -39,20 +38,12 @@ $examples = foreach ($package in $Packages | Where-Object { -not $_.Publish }) { # tree, the examples included, so the whole repository carries the version # being released. The publishing plugin writes the one bundle for the whole # reactor under the first tree that publishes, and common-ci finds it there. +# It reads the signing keys from the environment of the job that signs. ./java/build-package.ps1 ` -RepoName $RepoName ` -Name $Name ` -Version $Version ` -VersionPaths $Packages.Path ` - -ExtraArgs "-DskipNativeBuild=true", "-pl", ($examples -join ',') ` - -JavaGpgKeyPassphrase $Keys['JavaGpgKeyPassphrase'] ` - -JavaPGP $Keys['JavaPGP'] ` - -CodeSigningKeyVaultName: $Keys['CodeSigningKeyVaultName'] ` - -CodeSigningKeyVaultUrl $Keys['CodeSigningKeyVaultUrl'] ` - -CodeSigningKeyVaultClientId $Keys['CodeSigningKeyVaultClientId'] ` - -CodeSigningKeyVaultTenantId $Keys['CodeSigningKeyVaultTenantId'] ` - -CodeSigningKeyVaultClientSecret $Keys['CodeSigningKeyVaultClientSecret'] ` - -CodeSigningKeyVaultCertificateName $Keys['CodeSigningKeyVaultCertificateName'] ` - -CodeSigningKeyVaultCertificateData $Keys['CodeSigningKeyVaultCertificateData'] + -ExtraArgs "-DskipNativeBuild=true", "-pl", ($examples -join ',') exit $LASTEXITCODE diff --git a/ci/fetch-assets.ps1 b/ci/fetch-assets.ps1 index 600d3f6fc..d30c9136f 100644 --- a/ci/fetch-assets.ps1 +++ b/ci/fetch-assets.ps1 @@ -1,11 +1,9 @@ -param ( - [string]$DeviceDetection, - [string]$DeviceDetectionUrl, - [string]$IpIntelligence, - [string]$IpIntelligenceUrl -) $ErrorActionPreference = "Stop" +# common-ci's step downloads the TAC and Enterprise data files from the +# Distributor with the license key in _51DEGREES_LICENSE_KEY, which it +# exports before this runs. + # Tests and examples find data files by searching below the repository root, # so every asset is linked into the folders of the data repository, which is # the data submodule of cxx. @@ -13,13 +11,13 @@ $data = "$PSScriptRoot/../cxx/data" $deviceDetectionData = "$data/device-detection" $ipIntelligenceData = "$data/ip-intelligence" -$deviceDetectionAssets = 'TAC-HashV41.hash', '51Degrees-LiteV4.1.hash', '20000 Evidence Records.yml', '20000 User Agents.csv' -./steps/fetch-assets.ps1 -DeviceDetection:$DeviceDetection -DeviceDetectionUrl:$DeviceDetectionUrl -Assets $deviceDetectionAssets +$deviceDetectionAssets = 'TAC-HashV41.hash', '51Degrees-LiteV4.1.hash', '20000 Evidence Records.yml' +./steps/fetch-assets.ps1 -Assets $deviceDetectionAssets foreach ($asset in $deviceDetectionAssets) { New-Item -ItemType SymbolicLink -Force -Target "$PWD/assets/$asset" -Path "$deviceDetectionData/$asset" } -./steps/fetch-assets.ps1 -IpIntelligence:$IpIntelligence -IpIntelligenceUrl:$IpIntelligenceUrl -Assets '51Degrees-EnterpriseIpiV41.ipi', '51Degrees-LiteIpiV41.ipi', '51Degrees-IPIV4AsnIpiV41.ipi' +./steps/fetch-assets.ps1 -Assets '51Degrees-EnterpriseIpiV41.ipi', '51Degrees-LiteIpiV41.ipi', '51Degrees-IPIV4AsnIpiV41.ipi' New-Item -ItemType SymbolicLink -Force -Target "$PWD/assets/51Degrees-EnterpriseIpiV41.ipi" -Path "$ipIntelligenceData/51Degrees-EnterpriseIpiV41.ipi" # The asset is fetched under the blob name, but the tests, DataFileHelper and # the data repository scripts use the unpacked name 51Degrees-LiteV41.ipi, so diff --git a/ci/publish-package.ps1 b/ci/publish-package.ps1 index f2ee093f3..9c0757b26 100644 --- a/ci/publish-package.ps1 +++ b/ci/publish-package.ps1 @@ -1,12 +1,12 @@ param( [Parameter(Mandatory)][string]$RepoName, [Parameter(Mandatory)][string]$Version, - [Parameter(Mandatory)][Hashtable]$Keys, [bool]$DryRun = $false ) # Uploads the one publishing bundle build-package.ps1 made, which holds the -# packages of every tree that publishes. -./java/publish-package-maven.ps1 -RepoName $RepoName -MavenSettings $Keys['MavenSettings'] -Version $Version -DryRun $DryRun +# packages of every tree that publishes. common-ci's script reads the Central +# Portal token from the environment of the job that publishes. +./java/publish-package-maven.ps1 -RepoName $RepoName -Version $Version -DryRun $DryRun exit $LASTEXITCODE diff --git a/ci/run-integration-tests.ps1 b/ci/run-integration-tests.ps1 index ff9175676..da6e6bfb5 100644 --- a/ci/run-integration-tests.ps1 +++ b/ci/run-integration-tests.ps1 @@ -3,13 +3,16 @@ param( [string]$Name, # Set by the publish workflow to the version it built and installed. Not # set when a pull request is tested, which builds the reactor itself. - [string]$Version, - [string]$TestResourceKey, - [string]$DeviceDetection, - [string]$IpIntelligence, - [string]$IpIntelligenceUrl + [string]$Version ) $ErrorActionPreference = "Stop" + +# The shared workflow exports each secret under its own name before this runs. +# The tests take the resource key that carries every property, and the data +# license, which the Enterprise data files were fetched with. +$TestResourceKey = $env:_51DEGREES_RESOURCE_KEY_BESPOKE +$LicenseKey = $env:_51DEGREES_LICENSE_KEY + # Each part's exit code is checked below, so one failing part does not stop # the others from running. $PSNativeCommandUseErrorActionPreference = $false @@ -48,16 +51,10 @@ Write-Host "::endgroup::" # against the reactor, so they are run here only against a published version. if ($Version) { $examples = @( - @{ Path = 'examples/device-detection'; LicenseKey = $DeviceDetection; Run = $true } - # The IP Intelligence examples need the Enterprise data file, which is - # only fetched when its URL is given. - @{ Path = 'examples/ip-intelligence'; LicenseKey = $IpIntelligence; Run = [bool]$IpIntelligenceUrl } + @{ Path = 'examples/device-detection'; LicenseKey = $LicenseKey } + @{ Path = 'examples/ip-intelligence'; LicenseKey = $LicenseKey } ) foreach ($example in $examples) { - if (-not $example.Run) { - Write-Host "::warning title=Examples skipped::Skipping '$($example.Path)', as IpIntelligenceUrl was not provided." - continue - } Write-Host "::group::$($example.Path) against $Version" Push-Location "$RepoName/$($example.Path)" try { diff --git a/ci/run-performance-tests.ps1 b/ci/run-performance-tests.ps1 index 9b24f7024..fb77bbc80 100644 --- a/ci/run-performance-tests.ps1 +++ b/ci/run-performance-tests.ps1 @@ -3,8 +3,7 @@ param( [Parameter(Mandatory)][string]$Name, # Set by the publish workflow to the version it built and installed. Not # set when a pull request is tested, which builds the reactor itself. - [string]$Version, - [string]$IpIntelligenceUrl + [string]$Version ) $ErrorActionPreference = "Stop" # Each product's exit code is checked below, so one failing product does not @@ -103,25 +102,19 @@ $benchmarks = @( Output = 'console/target/surefire-reports/fiftyone.devicedetection.examples.console.PerformanceBenchmarkTest-output.txt' ProfileHeader = "MaxPerformance AllProperties: (true|false), performanceGraph: (true|false), predictiveGraph (true|false)" ProfileName = 'MaxPerformance-false-true-false' - Run = $true } + # Measured with the Enterprise data file, which fetch-assets.ps1 fetched + # with the data license. @{ Product = 'IpIntelligence' Path = 'examples/ip-intelligence' Output = 'console/target/surefire-reports/fiftyone.ipintelligence.examples.console.PerformanceBenchmarkTest-output.txt' ProfileHeader = "MaxPerformance AllProperties: (true|false)" ProfileName = 'MaxPerformance-false' - # Measured with the Enterprise data file, which is only fetched when - # its URL is given. - Run = [bool]$IpIntelligenceUrl } ) foreach ($benchmark in $benchmarks) { - if (-not $benchmark.Run) { - Write-Host "::warning title=Performance skipped::Skipping the $($benchmark.Product) benchmark, as IpIntelligenceUrl was not provided." - continue - } Write-Host "::group::$($benchmark.Product)" Push-Location "$RepoName/$($benchmark.Path)" try { diff --git a/ci/run-unit-tests.ps1 b/ci/run-unit-tests.ps1 index a54755337..261e02f75 100644 --- a/ci/run-unit-tests.ps1 +++ b/ci/run-unit-tests.ps1 @@ -1,11 +1,15 @@ param( [Parameter(Mandatory)][string]$RepoName, - [string]$Name, - [string]$TestResourceKey, - [string]$DeviceDetection + [string]$Name ) $ErrorActionPreference = "Stop" +# The shared workflow exports each secret under its own name before this runs. +# The tests take the resource key that carries every property, and the data +# license. +$TestResourceKey = $env:_51DEGREES_RESOURCE_KEY_BESPOKE +$LicenseKey = $env:_51DEGREES_LICENSE_KEY + # One run of every test in the reactor that build-project.ps1 built, the # examples included. common-ci runs Surefire from the root, copies the reports # of every module at any depth into test-results/unit, leaving out the example @@ -18,7 +22,7 @@ $ErrorActionPreference = "Stop" '-Pdev' "-DTestResourceKey=$TestResourceKey" "-DSuperResourceKey=$TestResourceKey" - "-DLicenseKey=$DeviceDetection" + "-DLicenseKey=$LicenseKey" ) exit $LASTEXITCODE