-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Delete Test Seed | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
paths: | ||
- 'studies/**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
if: github.event.pull_request.merged == true | ||
env: | ||
REMOTE_SEED_PATH: 'pull/${{ github.event.pull_request.number }}/seed' | ||
|
||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | ||
|
||
- name: Delete seed | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PRODUCTION_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PRODUCTION_SECRET_ACCESS_KEY }} | ||
AWS_REGION: us-west-2 | ||
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} | ||
run: | | ||
aws s3 rm "s3://brave-production-griffin-origin/$REMOTE_SEED_PATH" | ||
aws cloudfront create-invalidation --distribution-id "$CLOUDFRONT_DISTRIBUTION_ID" --paths "/$REMOTE_SEED_PATH" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Creates or updates a single comment which is looked up by the workflow name. | ||
|
||
module.exports = async (github, context, commentBody) => { | ||
const assert = require('assert'); | ||
assert(commentBody); | ||
|
||
const uniqueCommentTag = `<!-- ${context.workflow} -->`; | ||
commentBody += `\n${uniqueCommentTag}`; | ||
|
||
const comments = await github.rest.issues.listComments({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
|
||
const existingComment = comments.data.find((comment) => | ||
comment.body.includes(uniqueCommentTag), | ||
); | ||
|
||
if (existingComment) { | ||
await github.rest.issues.updateComment({ | ||
comment_id: existingComment.id, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: commentBody, | ||
}); | ||
} else { | ||
await github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: commentBody, | ||
}); | ||
} | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Upload Test Seed | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'studies/**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
REMOTE_SEED_PATH: 'pull/${{ github.event.pull_request.number }}/seed' | ||
|
||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | ||
|
||
- name: Comment "Upload In Progress" | ||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
with: | ||
script: | | ||
const commentBody = | ||
`## 🔄 Test Seed Upload In Progress | ||
A new seed file is currently being uploaded for this pull request. | ||
### What's Next? | ||
- The upload process typically takes a few minutes. | ||
- Once the upload is complete, a follow-up comment will provide the seed details and testing instructions. | ||
` | ||
const comment = require('.github/workflows/scripts/comment.js') | ||
await comment(github, context, commentBody) | ||
- name: Install dependencies and run tests | ||
run: | | ||
npm install | ||
npm run typecheck:scriptsa | ||
npm run build:proto | ||
npm run typecheck | ||
npm run test | ||
- name: Generate seed | ||
run: | | ||
npm run seed_tools -- create_seed studies seed.bin | ||
- name: Upload seed | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PRODUCTION_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PRODUCTION_SECRET_ACCESS_KEY }} | ||
AWS_REGION: us-west-2 | ||
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} | ||
run: | | ||
gzip -c seed.bin | aws s3 cp - "s3://brave-production-griffin-origin/$REMOTE_SEED_PATH" \ | ||
--content-type application/octet-stream \ | ||
--content-encoding gzip | ||
INVALIDATION_ID=$(aws cloudfront create-invalidation --distribution-id "$CLOUDFRONT_DISTRIBUTION_ID" --paths "/$REMOTE_SEED_PATH" --query 'Invalidation.Id' --output text) | ||
aws cloudfront wait invalidation-completed --distribution-id "$CLOUDFRONT_DISTRIBUTION_ID" --id "$INVALIDATION_ID" | ||
- name: Comment "Upload Successful" | ||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const variationsServerURL = `https://griffin.brave.com/${process.env.REMOTE_SEED_PATH}`; | ||
const serialNumberContent = fs.readFileSync('serialnumber', 'utf8'); | ||
const commentBody = | ||
`## 🚀 Test Seed Upload Successful | ||
To test the new seed, launch the browser with the following command line: | ||
\`\`\` | ||
--accept-empty-variations-seed-signature --variations-server-url=${variationsServerURL} | ||
\`\`\` | ||
#### Seed Details | ||
- Serial Number: \`${serialNumberContent}\` | ||
- Uploaded: \`${new Date().toISOString()}\` | ||
` | ||
const comment = require('.github/workflows/scripts/comment.js') | ||
await comment(github, context, commentBody) | ||
- name: Comment "Upload Failed" | ||
if: failure() | ||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
with: | ||
script: | | ||
const actionRunURL = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; | ||
const commentBody = | ||
`## ❌ Test Seed Upload Failed | ||
[View Workflow Run](${actionRunURL}) | ||
` | ||
const comment = require('.github/workflows/scripts/comment.js') | ||
await comment(github, context, commentBody) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[ | ||
{ | ||
"name": "AdBlockComponentUpdateIntervalStudy", | ||
"experiment": [ | ||
{ | ||
"name": "Enabled", | ||
"probability_weight": 100, | ||
"feature_association": { | ||
"enable_feature": [ | ||
"AdBlockDefaultResourceUpdateInterval" | ||
] | ||
}, | ||
"param": [ | ||
{ | ||
"name": "update_interval_mins", | ||
"value": "1" | ||
} | ||
] | ||
} | ||
], | ||
"filter": { | ||
"channel": [ | ||
"NIGHTLY", | ||
"BETA", | ||
"RELEASE" | ||
], | ||
"platform": [ | ||
"PLATFORM_WINDOWS", | ||
"PLATFORM_MAC", | ||
"PLATFORM_LINUX", | ||
"PLATFORM_ANDROID" | ||
] | ||
} | ||
} | ||
] |