Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(ci): run the PR tests on the self-hosted runner (#18083)
Дамян Минков409539022e0c
diff --git a/.github/workflows/pr-torture-trigger.yml b/.github/workflows/pr-torture-trigger.ymlnew file mode 100644index 0000000000..64677ba84a--- /dev/null+++ b/.github/workflows/pr-torture-trigger.yml@@ -0,0 +1,132 @@+# Decides who can run the PR tests (pr-torture.yml) on the self-hosted runner. Two org teams,+# named in the org variables PR_TEST_ADMIN_TEAM and PR_TEST_TRUSTED_TEAM:+# admins: start the tests on any PR commenting "ok to test", force a new run with "test this please",+# or run them from the Actions tab for a PR number+# trusted: their own PRs run on every push, and they can force a new run of their own PR+# with "test this please"+# Any other PR runs only when an admin starts it, and only for the commit the PR is at then.+# The dial-in tests, which need the VoxImplant credentials, run only for PRs of admins and trusted members.+#+# The authorize job never checks out the PR. pull_request_target and issue_comment run this file from+# the default branch, a PR cannot change it.+name: PR torture++on:+ pull_request_target:+ types: [opened, reopened, synchronize]+ issue_comment:+ types: [created]+ workflow_dispatch:+ inputs:+ pr-number:+ description: 'The PR to test'+ required: true+ type: string++permissions: {}++jobs:+ authorize:+ if: >-+ github.event_name != 'issue_comment' ||+ (github.event.issue.pull_request &&+ (contains(github.event.comment.body, 'ok to test') || contains(github.event.comment.body, 'test this please')))+ runs-on: ubuntu-latest+ permissions:+ issues: write+ pull-requests: write+ outputs:+ run: ${{ steps.decide.outputs.run }}+ author-trusted: ${{ steps.decide.outputs.author-trusted }}+ pr-number: ${{ steps.decide.outputs.pr-number }}+ head-sha: ${{ steps.decide.outputs.head-sha }}+ pr-repo-url: ${{ steps.decide.outputs.pr-repo-url }}+ pr-branch: ${{ steps.decide.outputs.pr-branch }}+ target-branch: ${{ steps.decide.outputs.target-branch }}+ steps:+ # Only reads the team memberships and the PR+ - name: GitHub App token+ id: app-token+ uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 #v3.3.0+ with:+ app-id: ${{ secrets.PR_TORTURE_APP_ID }}+ private-key: ${{ secrets.PR_TORTURE_APP_KEY }}+ owner: jitsi+ repositories: ${{ github.event.repository.name }}+ permission-members: read+ permission-pull-requests: read++ - name: Decide+ id: decide+ env:+ GH_TOKEN: ${{ steps.app-token.outputs.token }}+ ADMIN_TEAM: ${{ vars.PR_TEST_ADMIN_TEAM }}+ TRUSTED_TEAM: ${{ vars.PR_TEST_TRUSTED_TEAM }}+ EVENT: ${{ github.event_name }}+ PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number || inputs.pr-number }}+ ACTOR: ${{ github.event.comment.user.login || github.actor }}+ COMMENT: ${{ github.event.comment.body }}+ run: |+ in_team() {+ [ -n "$1" ] && [ "$(gh api "orgs/jitsi/teams/$1/memberships/$2" --jq .state 2>/dev/null)" = "active" ]+ }++ PR_JSON=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER")+ AUTHOR=$(jq -r .user.login <<< "$PR_JSON")+ STATE=$(jq -r .state <<< "$PR_JSON")++ AUTHOR_TRUSTED=false+ if in_team "$ADMIN_TEAM" "$AUTHOR" || in_team "$TRUSTED_TEAM" "$AUTHOR"; then+ AUTHOR_TRUSTED=true+ fi++ RUN=false+ if [ "$STATE" != "open" ]; then+ echo "PR #$PR_NUMBER is $STATE, not testing it"+ elif [ "$EVENT" = "pull_request_target" ]; then+ RUN=$AUTHOR_TRUSTED+ elif in_team "$ADMIN_TEAM" "$ACTOR"; then+ RUN=true+ elif [ "$EVENT" = "issue_comment" ] && [[ "${COMMENT,,}" == *"test this please"* ]] \+ && [ "$ACTOR" = "$AUTHOR" ] && in_team "$TRUSTED_TEAM" "$ACTOR"; then+ RUN=true+ fi+ echo "PR #$PR_NUMBER by $AUTHOR (trusted: $AUTHOR_TRUSTED), $EVENT by $ACTOR: run=$RUN"++ {+ echo "run=$RUN"+ echo "author-trusted=$AUTHOR_TRUSTED"+ echo "pr-number=$PR_NUMBER"+ echo "head-sha=$(jq -r .head.sha <<< "$PR_JSON")"+ echo "pr-repo-url=$(jq -r .head.repo.clone_url <<< "$PR_JSON")"+ echo "pr-branch=$(jq -r .head.ref <<< "$PR_JSON")"+ echo "target-branch=$(jq -r .base.ref <<< "$PR_JSON")"+ } >> "$GITHUB_OUTPUT"++ - name: Acknowledge the comment+ if: github.event_name == 'issue_comment'+ env:+ GH_TOKEN: ${{ github.token }}+ COMMENT_ID: ${{ github.event.comment.id }}+ REACTION: ${{ steps.decide.outputs.run == 'true' && 'rocket' || '-1' }}+ run: |+ gh api "repos/$GITHUB_REPOSITORY/issues/comments/$COMMENT_ID/reactions" -f content="$REACTION" > /dev/null++ pr-torture:+ needs: authorize+ if: needs.authorize.outputs.run == 'true'+ uses: ./.github/workflows/pr-torture.yml+ with:+ project: jitsi-meet+ pr-repo-url: ${{ needs.authorize.outputs.pr-repo-url }}+ pr-branch: ${{ needs.authorize.outputs.pr-branch }}+ target-branch: ${{ needs.authorize.outputs.target-branch }}+ pr-number: ${{ needs.authorize.outputs.pr-number }}+ head-sha: ${{ needs.authorize.outputs.head-sha }}+ dial-in: ${{ needs.authorize.outputs.author-trusted == 'true' }}+ secrets:+ PR_TORTURE_APP_ID: ${{ secrets.PR_TORTURE_APP_ID }}+ PR_TORTURE_APP_KEY: ${{ secrets.PR_TORTURE_APP_KEY }}+ VOX_API_KEY: ${{ secrets.VOX_API_KEY }}+ VOX_ACCOUNT_ID: ${{ secrets.VOX_ACCOUNT_ID }}+ VOX_HEALTH_CHECK_IN_RULE_ID: ${{ secrets.VOX_HEALTH_CHECK_IN_RULE_ID }}diff --git a/.github/workflows/pr-torture.yml b/.github/workflows/pr-torture.ymlnew file mode 100644index 0000000000..0391d3ca12--- /dev/null+++ b/.github/workflows/pr-torture.yml@@ -0,0 +1,179 @@+# Runs the PR tests (jitsi-pr-testing-scripts) on the self-hosted runner on oracle-prtorture.+# Called by pr-torture-trigger.yml here and by the same workflow in lib-jitsi-meet, jicofo,+# jitsi-videobridge and jicoco, after it decided the PR may be tested.+name: PR torture tests++on:+ workflow_call:+ inputs:+ project:+ description: 'jitsi-meet, lib-jitsi-meet, jicofo, jitsi-videobridge or jicoco'+ required: true+ type: string+ pr-repo-url:+ required: true+ type: string+ pr-branch:+ required: true+ type: string+ target-branch:+ required: true+ type: string+ pr-number:+ required: true+ type: string+ head-sha:+ required: true+ type: string+ scripts-ref:+ description: 'The branch of jitsi-pr-testing-scripts to use'+ required: false+ type: string+ default: master+ dial-in:+ description: 'Run the dial-in tests, they get the VoxImplant credentials (only for trusted authors)'+ required: false+ type: boolean+ default: false+ secrets:+ PR_TORTURE_APP_ID:+ required: true+ PR_TORTURE_APP_KEY:+ required: true+ VOX_API_KEY:+ required: false+ VOX_ACCOUNT_ID:+ required: false+ VOX_HEALTH_CHECK_IN_RULE_ID:+ required: false++permissions: {}++jobs:+ # Runs the PR code, so it gets no GitHub token that can write anything, and the VoxImplant+ # credentials only for the dial-in tests of trusted authors.+ # The runner runs as ghrunner, the tests as jenkins (sudo, /usr/local/bin/pr-torture-run), so the PR+ # code can't read the runner's credentials or the ssh key.+ pr-torture:+ # One runner with one job at a time per repo. build-pr.sh also takes /var/lock/pr-torture, so the+ # runs of the different repos and the ones started by Jenkins wait for each other on the machine.+ runs-on: [self-hosted, pr-torture]+ timeout-minutes: 120+ concurrency:+ group: pr-torture-${{ inputs.project }}-${{ inputs.pr-number }}+ cancel-in-progress: true+ env:+ SCRIPTS_SRC: /var/lib/pr-torture/scripts/${{ inputs.project }}+ PR_TEST_WORKSPACE: /var/lib/pr-torture/work/${{ inputs.project }}+ TORTURE_REMOTE_ADDRESS: ${{ vars.PR_TORTURE_GRID_URL }}+ HEAD_SHA: ${{ inputs.head-sha }}+ # Test only the commit the PR was approved at+ PR_TEST_REQUIRE_SHA: true+ steps:+ # With the ghrunner ssh key, a deploy key of the scripts repo+ - name: Check out the PR testing scripts+ env:+ SCRIPTS_REF: ${{ inputs.scripts-ref }}+ run: |+ rm -rf "$SCRIPTS_SRC"+ git clone --depth 1 --branch "$SCRIPTS_REF" \+ [email protected]:jitsi/jitsi-pr-testing-scripts.git "$SCRIPTS_SRC"++ - name: Build and test+ env:+ # No permissions, only for reading the public PRs with a higher rate limit+ ACCESS_TOKEN: ${{ github.token }}+ VOX_API_KEY: ${{ inputs.dial-in && secrets.VOX_API_KEY || '' }}+ VOX_ACCOUNT_ID: ${{ inputs.dial-in && secrets.VOX_ACCOUNT_ID || '' }}+ VOX_HEALTH_CHECK_IN_RULE_ID: ${{ inputs.dial-in && secrets.VOX_HEALTH_CHECK_IN_RULE_ID || '' }}+ PROJECT: ${{ inputs.project }}+ PR_REPO_URL: ${{ inputs.pr-repo-url }}+ PR_BRANCH: ${{ inputs.pr-branch }}+ TARGET_BRANCH: ${{ inputs.target-branch }}+ run: |+ sudo -n -u jenkins -H \+ --preserve-env=PR_TEST_WORKSPACE,TORTURE_REMOTE_ADDRESS,HEAD_SHA,PR_TEST_REQUIRE_SHA,ACCESS_TOKEN,VOX_API_KEY,VOX_ACCOUNT_ID,VOX_HEALTH_CHECK_IN_RULE_ID \+ /usr/local/bin/pr-torture-run "$SCRIPTS_SRC" "$PROJECT" "$PR_REPO_URL" "$PR_BRANCH" "$TARGET_BRANCH"++ # The reports are written by the PR code: copy only regular files and directories, so a link to a+ # file of this user doesn't end up in the uploaded artifact.+ - name: Collect the test reports+ if: always()+ run: |+ OUT="$RUNNER_TEMP/pr-torture-reports"+ rm -rf "$OUT"+ mkdir -p "$OUT"+ for p in test-reports.zip chrome-chrome-reports ff-chrome-reports; do+ if [ -e "$PR_TEST_WORKSPACE/release/$p" ] && [ ! -L "$PR_TEST_WORKSPACE/release/$p" ]; then+ cp -R --no-dereference "$PR_TEST_WORKSPACE/release/$p" "$OUT/" || true+ fi+ done+ find "$OUT" ! -type f ! -type d -delete++ - name: Upload the test reports+ if: always()+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 #v7.0.2+ with:+ name: pr-torture-${{ inputs.project }}-${{ inputs.pr-number }}+ path: ${{ runner.temp }}/pr-torture-reports+ if-no-files-found: ignore++ # Publishes the reports and posts the check run, on a hosted runner, away from the PR code.+ report:+ needs: pr-torture+ if: ${{ !cancelled() }}+ runs-on: ubuntu-latest+ timeout-minutes: 20+ env:+ PR_NUMBER: ${{ inputs.pr-number }}+ HEAD_SHA: ${{ inputs.head-sha }}+ SOURCE_REPO: ${{ github.repository }}+ # Kept apart from the Jenkins builds while both run+ BUILD_NUMBER: gha-${{ github.run_id }}+ CHECK_NAME: ${{ inputs.project }}-PR-torture+ RELEASE_DIR: ${{ github.workspace }}/release+ steps:+ # The check run on the PR repo, the prosody tests results in jitsi-meet, reading the scripts+ - name: GitHub App token+ id: app-token+ uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 #v3.3.0+ with:+ app-id: ${{ secrets.PR_TORTURE_APP_ID }}+ private-key: ${{ secrets.PR_TORTURE_APP_KEY }}+ owner: jitsi+ repositories: ${{ github.event.repository.name == 'jitsi-meet' && 'jitsi-meet' || format('{0},jitsi-meet', github.event.repository.name) }},jitsi-pr-testing-scripts+ permission-checks: write+ permission-actions: read+ permission-contents: read++ # The reports pushed to jitsi-pr-tests-pages+ - name: GitHub App token for the reports+ id: pages-token+ uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 #v3.3.0+ with:+ app-id: ${{ secrets.PR_TORTURE_APP_ID }}+ private-key: ${{ secrets.PR_TORTURE_APP_KEY }}+ owner: jitsi+ repositories: jitsi-pr-tests-pages+ permission-contents: write++ - name: Check out the PR testing scripts+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1+ with:+ repository: jitsi/jitsi-pr-testing-scripts+ ref: ${{ inputs.scripts-ref }}+ token: ${{ steps.app-token.outputs.token }}+ path: jitsi-pr-testing-scripts+ persist-credentials: false++ - name: Download the test reports+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 #v8.0.2+ with:+ name: pr-torture-${{ inputs.project }}-${{ inputs.pr-number }}+ path: release++ - name: Publish the reports and the check run+ env:+ GH_TOKEN: ${{ steps.app-token.outputs.token }}+ PAGES_TOKEN: ${{ steps.pages-token.outputs.token }}+ run: jitsi-pr-testing-scripts/publish-pr-results.sh