Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test external change for PR labels #491

Closed
wants to merge 14 commits into from
35 changes: 35 additions & 0 deletions .github/workflows/auto_label_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: PR Auto Label

on:
pull_request_target:
types:
- opened
- reopened

concurrency:
group: '${{ github.workflow }}-${{ github.event_name }} @ ${{ github.event.pull_request.number || github.sha }}'
cancel-in-progress: true

jobs:
assign-reviewer:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Check if PR author is outside collaborator and assign reviewer
env:
PR_AUTHOR_LOGIN: ${{ github.event.pull_request.user.login }}
REPO_NAME: ${{ github.event.repository.full_name }}
PR_NUMBER: ${{ github.event.number }}
run: |
PERMISSION_LEVEL=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/$REPO_NAME/collaborators/$PR_AUTHOR_LOGIN/permission" | jq -r .role_name)

if [ "$PERMISSION_LEVEL" == "none" ] || [ "$PERMISSION_LEVEL" == "read" ]; then
echo "PR author is an outside collaborator. Adding label..."

curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '["outside collaborator"]' \
"https://api.github.com/repos/$REPO_NAME/issues/$PR_NUMBER/labels"
fi
35 changes: 35 additions & 0 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: testing

on:
pull_request:
types: [opened, reopened, synchronize, labeled]
branches:
- main
- feature/*
push:
branches:
- main
- feature/*
workflow_dispatch:
inputs:
nightly:
description: 'Nightly workflow.'
required: true
type: boolean
default: false

jobs:
linux-x64:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: kaidokert/[email protected]
with:
fetch-depth: 1
- name: Archive unit test report
uses: actions/upload-artifact@v3
# TODO: Should only run for unit-tests
if: always()
with:
name: unit-test-results
path: unit-test-results/
133 changes: 133 additions & 0 deletions .github/workflows/unit_test_report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Upload Unit Test Results

on:
# This workflow must be triggered via `workflow_run` to be able to access
# secrets, which is not possible from a workflow triggered by a PR in a fork.
workflow_run:
workflows:
- linux
# TODO: Temporary testing
- testing
# TODO: Download xml files from GCS
# - android
# - raspi
# TODO: Generate xml files
# - win32
# TODO: Get xml files from platforms
# - atv
# - ps
# - switch
# - xbox
types:
- completed

jobs:
# Gets unit test report from artifact storage and uploads them to DataDog.
unit-test-report:
permissions: {}
if: always()
runs-on: ubuntu-latest
name: Upload Unit Test Reports
steps:
- name: Collect Unit Test Reports
id: collect-report
uses: actions/github-script@v6
with:
script: |
console.log('context', context);
console.log('context.payload.workflow_run.pull_requests', context.payload.workflow_run.pull_requests);
console.log('context.payload.workflow_run.head_commit', context.payload.workflow_run.head_commit);

// The `download-artifact` action can only access artifacts that
// were uploaded in the same workflow. Since it was not this
// workflow that uploaded the artifacts we must use rest api
// to download them.
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow

let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
console.log(allArtifacts);
let matchArtifacts = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "unit-test-results"
});
console.log(matchArtifacts)
if (matchArtifacts.length == 0) {
// No reports were uploaded.
console.log('No unit test reports were uploaded');
return false;
}
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifacts[0].id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/unit-test-results.zip`, Buffer.from(download.data));
return true;
- run: unzip unit-test-results.zip -d unit-test-results
if: ${{ steps.collect-report.outputs.result == 'true' }}
- name: Install node
if: steps.collect-report.outputs.result
uses: actions/setup-node@v3
with:
node-version: 16
- name: Get Datadog CLI
if: ${{ steps.collect-report.outputs.result == 'true' }}
shell: bash
# TODO: pin version (with checksum?)
run: npm install -g @datadog/datadog-ci
- name: Upload the JUnit files
if: ${{ steps.collect-report.outputs.result == 'true' }}
shell: bash
env:
DATADOG_API_KEY: ${{ secrets.DD_API_KEY }}
DATADOG_SITE: us5.datadoghq.com
DD_ENV: ci
DD_SERVICE: ${{ github.event.repository.name }}
# TODO
# DD_METRICS:

# Git info
DD_GIT_REPOSITORY_URL: ${{ github.event.repository.git_url }}
DD_GIT_COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
DD_GIT_BRANCH: ${{ github.event.workflow_run.head_branch }}
DD_GIT_COMMIT_MESSAGE: ${{ github.event.workflow_run.head_commit.message }}
DD_GIT_COMMIT_AUTHOR_NAME: ${{ github.event.workflow_run.head_commit.author.name }}
DD_GIT_COMMIT_AUTHOR_EMAIL: ${{ github.event.workflow_run.head_commit.author.email }}
DD_GIT_COMMIT_AUTHOR_DATE: ${{ github.event.workflow_run.head_commit.timestamp }}
DD_GIT_COMMIT_COMMITTER_NAME: ${{ github.event.workflow_run.head_commit.committer.name }}
DD_GIT_COMMIT_COMMITTER_EMAIL: ${{ github.event.workflow_run.head_commit.committer.email }}
# TODO: Not available?
DD_GIT_COMMIT_COMMITTER_DATE: ${{ github.event.workflow_run.head_commit.timestamp }}
run: |
# Unit test results are archived on the following format:
#
# unit-test-results/
# ├── android-arm
# │ ├── <shards>
# │ │ └── <test result xmls>
# │ └── TAGS
# ├── linux-x64x11
# │ ├── <shards>
# │ │ └── <test result xmls>
# │ └── TAGS
# ├── raspi-2
# │ ├── <shards>
# │ │ └── <test result xmls>
# │ └── TAGS
# etc.

# Loop over each platform, extract the tags and upload xml results.
for dir in unit-test-results/*/; do
echo "Uploading $dir test report"

tags=`cat ${dir}TAGS`

datadog-ci junit upload \
--tags $tags \
$dir/**/*.xml
done
2 changes: 1 addition & 1 deletion starboard_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License."""
"""Definition of interface used by host apps to configure Starboard"""

# Test change
from cobalt.build import cobalt_configuration

# List of paths to directories in which Starboard ports are located. Each path
Expand Down