mirror of
https://github.com/recloudstream/cloudstream.git
synced 2026-07-13 00:13:17 +00:00
105 lines
3.3 KiB
YAML
105 lines
3.3 KiB
YAML
name: Instrumented Tests
|
|
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
instrumented-tests:
|
|
runs-on: ubuntu-latest
|
|
if: |
|
|
github.event.issue.pull_request &&
|
|
github.event.comment.body == '/run-tests'
|
|
steps:
|
|
- name: Check permission
|
|
uses: actions/github-script@v9
|
|
with:
|
|
script: |
|
|
const login = context.payload.comment.user.login;
|
|
const association = context.payload.comment.author_association;
|
|
const allowed = ['OWNER', 'MEMBER'];
|
|
|
|
const isAllowed =
|
|
login === 'Luna712' ||
|
|
allowed.includes(association);
|
|
|
|
if (!isAllowed) {
|
|
core.setFailed(`User ${login} is not permitted to trigger this workflow.`);
|
|
}
|
|
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
ref: refs/pull/${{ github.event.issue.number }}/head
|
|
|
|
- name: Post started comment
|
|
uses: actions/github-script@v9
|
|
with:
|
|
script: |
|
|
github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: 'Instrumented tests are running. [View live progress](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})'
|
|
})
|
|
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v5
|
|
with:
|
|
distribution: temurin
|
|
java-version: 17
|
|
|
|
- name: Grant execute permission for gradlew
|
|
run: chmod +x gradlew
|
|
|
|
- name: Setup Gradle
|
|
uses: gradle/actions/setup-gradle@v5
|
|
with:
|
|
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
|
cache-read-only: false
|
|
|
|
- name: Get target SDK
|
|
id: sdk
|
|
run: |
|
|
TARGET_SDK=$(grep 'targetSdk' gradle/libs.versions.toml | grep -o '[0-9]\+' | head -1)
|
|
echo "version=$TARGET_SDK" >> $GITHUB_OUTPUT
|
|
|
|
- name: Enable KVM
|
|
run: |
|
|
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
|
|
sudo udevadm control --reload-rules
|
|
sudo udevadm trigger --name-match=kvm
|
|
|
|
- name: Run Instrumented Tests
|
|
id: tests
|
|
uses: reactivecircus/android-emulator-runner@v2
|
|
with:
|
|
api-level: ${{ steps.sdk.outputs.version }}
|
|
arch: x86_64
|
|
profile: Nexus 6
|
|
script: ./gradlew connectedPrereleaseDebugAndroidTest
|
|
|
|
- name: Upload Test Results
|
|
if: always()
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: instrumented-test-results
|
|
path: '**/build/reports/androidTests/'
|
|
|
|
- name: Post finished comment
|
|
if: always()
|
|
uses: actions/github-script@v9
|
|
with:
|
|
script: |
|
|
const success = '${{ steps.tests.outcome }}' === 'success';
|
|
github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: success
|
|
? 'Instrumented tests passed. [View results](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})'
|
|
: 'Instrumented tests failed. [View results](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})'
|
|
})
|