jenkins: test jenkins in a loop #9
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: Get Commit Status on PR | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
jobs: | |
test-jenkins: | |
strategy: | |
matrix: | |
run_id: [1, 2] | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Push to tmp-jenkins branch | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git checkout -b __jenkins_test_run_${{ matrix.run_id }} | |
echo "TEST JENKINS ${{ matrix.run_id }}" >> test_file | |
git add test_file | |
git commit -m "test run ${{ matrix.run_id }}" | |
GIT_LFS_SKIP_PUSH=1 git push -f origin __jenkins_test_run_${{ matrix.run_id }} | |
- name: Get Commit Status | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
let prev_status = false; | |
setInterval(() => { | |
const response = github.request('GET /repos/{owner}/{repo}/commits/{ref}/status', { | |
owner: 'commaai', | |
repo: 'openpilot', | |
ref: 'heads/__jenkins_test_run_${{ matrix.run_id }}', | |
headers: { | |
'Accept': 'application/vnd.github+json', | |
'X-GitHub-Api-Version': '2022-11-28' | |
} | |
}); | |
if ((response.data.statuses === undefined || response.data.statuses == 0) && !prev_status) { | |
console.log('NOT STARTED! exit loop'); | |
} else { | |
prev_status = true; | |
console.log('in the loop'); | |
console.log(response.data.statuses); | |
} | |
}, 10000); |