BUILD-4175: use secrets from Vault
* Fix SQ issue Unexpected string concatenation * Allow testing of the coverage update workflow by checking out all branches and referencing the SHA of the triggering event * Fix repository url for coverage update * Add a manual trigger for coverage update
This commit is contained in:
parent
0f8222f73b
commit
c0a5024363
23
.github/workflows/update_coverage.yml
vendored
23
.github/workflows/update_coverage.yml
vendored
@ -2,20 +2,33 @@ name: Update rule coverage
|
|||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '17 2 * * *'
|
- cron: '17 2 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update_coverage:
|
update_coverage:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
contents: write
|
||||||
|
checks: read
|
||||||
env:
|
env:
|
||||||
TMP_BRANCH: temporary/coverage_update
|
TMP_BRANCH: temporary/coverage_update
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: 'get secrets'
|
||||||
|
id: secrets
|
||||||
|
uses: SonarSource/vault-action-wrapper@v3
|
||||||
|
with:
|
||||||
|
secrets: |
|
||||||
|
development/github/token/SonarSource-rspec-coverage token | coverage_github_token;
|
||||||
|
development/kv/data/slack token | slack_token;
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
persist-credentials: true
|
persist-credentials: true
|
||||||
ref: master
|
fetch-depth: 0
|
||||||
path: 'rspec'
|
path: 'rspec'
|
||||||
token: ${{ secrets.COVERAGE_GITHUB_TOKEN }}
|
token: ${{ fromJSON(steps.secrets.outputs.vault).coverage_github_token }}
|
||||||
|
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
@ -31,7 +44,7 @@ jobs:
|
|||||||
|
|
||||||
- name: 'Regenerate coverage information'
|
- name: 'Regenerate coverage information'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.COVERAGE_GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).coverage_github_token }}
|
||||||
id: gen-coverage
|
id: gen-coverage
|
||||||
working-directory: 'rspec/rspec-tools'
|
working-directory: 'rspec/rspec-tools'
|
||||||
run: |
|
run: |
|
||||||
@ -84,7 +97,7 @@ jobs:
|
|||||||
if: always() && steps.create-temp-branch.conclusion == 'success'
|
if: always() && steps.create-temp-branch.conclusion == 'success'
|
||||||
uses: dawidd6/action-delete-branch@v3
|
uses: dawidd6/action-delete-branch@v3
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN}}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
branches: ${{ env.TMP_BRANCH}}
|
branches: ${{ env.TMP_BRANCH}}
|
||||||
|
|
||||||
- name: 'Fail if the change breaks CI'
|
- name: 'Fail if the change breaks CI'
|
||||||
@ -96,7 +109,7 @@ jobs:
|
|||||||
- name: 'Notify on slack about the failure'
|
- name: 'Notify on slack about the failure'
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
env:
|
env:
|
||||||
SLACK_API_TOKEN: ${{ secrets.SLACK_API_TOKEN }}
|
SLACK_API_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).slack_token }}
|
||||||
working-directory: 'rspec/rspec-tools'
|
working-directory: 'rspec/rspec-tools'
|
||||||
run: |
|
run: |
|
||||||
pipenv run rspec-tools notify-failure-on-slack \
|
pipenv run rspec-tools notify-failure-on-slack \
|
||||||
|
@ -31,7 +31,7 @@ export async function process_incomplete_rspecs(tmpRepoDir: string,
|
|||||||
const repo = await (() => {
|
const repo = await (() => {
|
||||||
if (!fs.existsSync(path.join(tmpRepoDir, '.git'))) {
|
if (!fs.existsSync(path.join(tmpRepoDir, '.git'))) {
|
||||||
if (process.env.GITHUB_TOKEN) {
|
if (process.env.GITHUB_TOKEN) {
|
||||||
return Git.Clone.clone('https://' + process.env.GITHUB_TOKEN + '@github.com/SonarSource/rspec/', tmpRepoDir);
|
return Git.Clone.clone(`https://${process.env.GITHUB_TOKEN}@github.com/SonarSource/rspec/`, tmpRepoDir);
|
||||||
} else {
|
} else {
|
||||||
return Git.Clone.clone('https://github.com/SonarSource/rspec/', tmpRepoDir);
|
return Git.Clone.clone('https://github.com/SonarSource/rspec/', tmpRepoDir);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ def checkout_repo(repo):
|
|||||||
git_url=f"https://github.com/SonarSource/{repo}"
|
git_url=f"https://github.com/SonarSource/{repo}"
|
||||||
token=os.getenv('GITHUB_TOKEN')
|
token=os.getenv('GITHUB_TOKEN')
|
||||||
if token:
|
if token:
|
||||||
git_url=f"https://{token}@github.com/SonarSource/{repo}"
|
git_url=f"https://oauth2:{token}@github.com/SonarSource/{repo}"
|
||||||
if not os.path.exists(repo):
|
if not os.path.exists(repo):
|
||||||
return Repo.clone_from(git_url, repo)
|
return Repo.clone_from(git_url, repo)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user