Update Privacy Reference Tests #1
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
name: Update Privacy Reference Tests | |
on: | |
schedule: | |
- cron: '0 1 * * *' # run at 1 AM UTC | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
update-ref-tests: | |
name: Update reference tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Install npm-check-updates | |
run: npm install -g npm-check-updates | |
- name: Install copy-files-from-to | |
run: npm install -g copy-files-from-to | |
- name: Check for updates | |
id: update-check | |
continue-on-error: true | |
run: ncu @duckduckgo/privacy-reference-tests --errorLevel 2 | |
- name: Update reference steps | |
if: ${{ steps.update-check.outcome == 'failure' }} | |
run: ncu @duckduckgo/privacy-reference-tests -u | |
- name: Install package | |
if: ${{ steps.update-check.outcome == 'failure' }} | |
run: npm update | |
- name: Copy files | |
if: ${{ steps.update-check.outcome == 'failure' }} | |
run: copy-files-from-to | |
- name: Find latest release version of Content Scope scripts in package.json | |
if: ${{ steps.update-check.outcome == 'failure' }} | |
id: find-latest-release | |
uses: notiz-dev/github-action-json-property@release | |
with: | |
path: 'package.json' | |
prop_path: 'dependencies.@duckduckgo/privacy-reference-tests' | |
- name: Extract release version | |
if: ${{ steps.update-check.outcome == 'failure' }} | |
uses: rishabhgupta/split-by@v1 | |
id: extract-release-version | |
with: | |
string: ${{steps.find-latest-release.outputs.prop}} | |
split-by: '#' | |
- name: Create Pull Request in Android repo | |
if: ${{ steps.update-check.outcome == 'failure' }} | |
env: | |
RELEASE_VERSION: ${{ steps.extract-release-version.outputs._1}} | |
id: create-pr | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
base: "develop" | |
title: Update reference tests to version ${{ steps.extract-release-version.outputs._1}} | |
author: daxmobile <daxmobile@users.noreply.github.com> | |
token: ${{ secrets.GT_DAXMOBILE }} | |
commit-message: Update content scope scripts to version ${{ steps.extract-release-version.outputs._1}} | |
labels: reference tests, automated pr | |
branch: automated/update-ref-tests-dependencies-${{ steps.extract-release-version.outputs._1}} | |
body: | | |
- Automated reference tests dependency update | |
This PR updates the reference tests dependency to the latest available version and copies the necessary files. | |
If tests have failed, see https://app.asana.com/0/0/1203766026095653/f for further information on what to do next. | |
- [ ] All tests must pass | |
- name: Create Asana task in Android App project | |
if: ${{ steps.update-check.outcome == 'failure' }} | |
id: create-task | |
uses: duckduckgo/native-github-asana-sync@v1.1 | |
with: | |
asana-pat: ${{ secrets.GH_ASANA_SECRET }} | |
asana-project: ${{ vars.GH_ANDROID_APP_PROJECT_ID }} | |
asana-section: ${{ vars.GH_ANDROID_APP_INCOMING_SECTION_ID }} | |
asana-task-name: Update reference tests to version ${{ steps.extract-release-version.outputs._1}} | |
asana-task-description: | | |
Reference tests have been updated and a PR created. | |
If tests failed check out https://app.asana.com/0/0/1203766026095653/f for further information on what to do next. | |
See ${{ steps.create-pr.outputs.pull-request-url }} | |
action: 'create-asana-task' | |
- name: Add Asana task to Release Board project | |
if: ${{ steps.create-task.outputs.duplicate == 'false' }} | |
uses: duckduckgo/native-github-asana-sync@v1.1 | |
with: | |
asana-pat: ${{ secrets.GH_ASANA_SECRET }} | |
asana-project: ${{ vars.GH_ANDROID_RELEASE_BOARD_PROJECT_ID }} | |
asana-section: ${{ vars.GH_ANDROID_RELEASE_BOARD_PR_SECTION_ID }} | |
asana-task-id: ${{ steps.create-task.outputs.taskId }} | |
action: 'add-task-asana-project' | |
- name: Update PR description with Asana task | |
if: ${{ steps.create-task.outputs.duplicate == 'false' }} | |
uses: duckduckgo/native-github-asana-sync@v1.1 | |
with: | |
github-pat: ${{ secrets.GT_DAXMOBILE }} | |
github-pr: ${{ steps.create-pr.outputs.pull-request-number }} | |
github-repository: 'android' | |
github-org: 'duckduckgo' | |
asana-project: ${{ vars.GH_ANDROID_RELEASE_BOARD_PROJECT_ID }} | |
asana-task-id: ${{ steps.create-task.outputs.taskId }} | |
action: 'add-task-pr-description' | |
- name: Create Asana task when workflow failed | |
if: ${{ failure() }} | |
uses: duckduckgo/native-github-asana-sync@v1.1 | |
with: | |
asana-pat: ${{ secrets.GH_ASANA_SECRET }} | |
asana-project: ${{ vars.GH_ANDROID_APP_PROJECT_ID }} | |
asana-section: ${{ vars.GH_ANDROID_APP_INCOMING_SECTION_ID }} | |
asana-task-name: GH Workflow Failure - Update reference tests | |
asana-task-description: The update reference tests workflow has failed. See https://github.com/duckduckgo/Android/actions/runs/${{ github.run_id }} | |
action: 'create-asana-task' |