1- # This workflow is used to invoke the PSDB jenkins job for ROCm Compiler CI. The python script can be used to invoke any jenkins job but input params needs to be configured properly
2- name : Compiler CI test
1+ name : Compiler CI PSDB trigger on amd-mainline branch
32
43# Controls when the workflow will run
54on :
109
1110# A workflow run is made up of one or more jobs that can run sequentially or in parallel, below is a single job called invoke jenkins jobs
1211jobs :
13- # This workflow contains a single job called "build "
12+ # This workflow contains a single job called "invoke_jenkins_PSDB "
1413 invoke_jenkins_PSDB :
15- # The type of runner that the job will run on. For github hosted runner use (${{ 'ubuntu-latest' }}) or self-hosted for sel-hosted runner.
16- # runs-on: ubuntu-latest
1714 if : github.event.pull_request.draft == false
18- runs-on : self-hosted
19- container :
20- image : compute-artifactory.amd.com:5000/rocm-base-images/ghemu-action-ubuntu-24.04:2024101101
15+ runs-on :
16+ group : compiler-generic-runners
2117 env :
22- svc_acc_org_secret : ${{'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' }}
18+ svc_acc_org_secret : ${{secrets.CI_GITHUB_TOKEN }}
2319 input_sha : ${{ github.event.pull_request.head.sha != '' && github.event.pull_request.head.sha || github.sha }}
2420 input_pr_num : ${{ github.event.pull_request.number != '' && github.event.pull_request.number || 0 }}
2521 input_pr_url : ${{ github.event.pull_request.html_url != '' && github.event.pull_request.html_url || '' }}
2622 input_pr_title : ${{ github.event.pull_request.title != '' && github.event.pull_request.title || '' }}
2723 # set the pipeline name here based on branch name
28- pipeline_name : ${{ 'compiler-psdb-amd-mainline' }}
29- JENKINS_URL : ${{'https://compiler-ci.amd.com/'}}
24+ pipeline_name : ${{secrets.CI_JENKINS_MAINLINE_JOB_NAME}}
25+ JENKINS_URL : ${{secrets.CI_JENKINS_URL}}
26+ CONTAINER_IMAGE : ${{ secrets.JENKINS_TRIGGER_DOCKER_IMAGE }}
27+
3028 # Steps represent a sequence of tasks that will be executed as part of the job
31- steps :
32- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
33- - name : Check out rocm_ci_infra private repo
34- uses : actions/checkout@main
35- with :
36- # ref: ci-utils-dev-siva
37- # fetch-depth: 2
38- repository : AMD-Lightning-Internal/ci-utils
39- token : ${{ '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' }}
40- # token: ${{'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'}}
29+ steps :
4130
31+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
32+ - name : Set environment variable for container image
33+ run : |
34+ echo "CONTAINER_IMAGE=${{ secrets.JENKINS_TRIGGER_DOCKER_IMAGE }}" >> $GITHUB_ENV
35+ echo "CONTAINER_NAME=my_container_${{ github.run_id }}" >> $GITHUB_ENV
36+
37+
38+ - name : Pull container image
39+ run : docker pull "${{env.CONTAINER_IMAGE}}"
4240
41+
42+ - name : Run container
43+ run : |
44+ docker run -d --name "${{env.CONTAINER_NAME}}" $CONTAINER_IMAGE sleep infinity
45+ #docker exec "${{env.CONTAINER_NAME}}" /bin/bash -c "git clone ${{secrets.CI_UTILS_REPO}} ."
46+ docker exec "${{env.CONTAINER_NAME}}" /bin/bash -c "echo 'Running commands inside the container'"
47+
48+ - name : Escape pull request title
49+ run : |
50+ import json
51+ import os
52+ import shlex
53+ with open('${{ github.event_path }}') as fh:
54+ event = json.load(fh)
55+ escaped = event['pull_request']['title']
56+ with open(os.environ['GITHUB_ENV'], 'a') as fh:
57+ print(f'PR_TITLE={escaped}', file=fh)
58+ shell : python3 {0}
59+
4360 - name : Run Jenkins Cancel Script
4461 env :
45- JENKINS_URL : ${{ 'https://compiler-ci.amd.com/' }}
46- JENKINS_USER : ${{ 'z1_cciauto' }}
47- JENKINS_API_TOKEN : ${{ '11bdb3dcd61f1a00f3999c8e3a0d6da9a7' }}
48- JENKINS_JOB_NAME : ${{ 'compiler-psdb-amd-mainline' }}
62+ JENKINS_URL : ${{secrets.CI_JENKINS_URL }}
63+ JENKINS_USER : ${{secrets.CI_JENKINS_USER }}
64+ JENKINS_API_TOKEN : ${{secrets.CI_JENKINS_TOKEN }}
65+ JENKINS_JOB_NAME : ${{secrets.CI_JENKINS_JOB_NAME }}
4966 PR_NUMBER : ${{ github.event.pull_request.number }}
5067 COMMIT_HASH : ${{ github.event.after }}
5168 run : |
52- python3 cancel_previous_build.py
69+ docker exec -e JENKINS_JOB_NAME=${{secrets.CI_JENKINS_JOB_NAME}} -e PR_NUMBER=${{ github.event.pull_request.number }} -e COMMIT_HASH=${{ github.event.after }} -e JENKINS_URL=${{secrets.CI_JENKINS_URL}} -e JENKINS_USER=${{secrets.CI_JENKINS_USER}} -e JENKINS_API_TOKEN=${{secrets.CI_JENKINS_TOKEN}} "${{env.CONTAINER_NAME}}" /bin/bash -c "PYTHONHTTPSVERIFY=0 python3 cancel_previous_build.py"
5370
5471
5572 # Runs a set of commands using the runners shell
@@ -65,21 +82,25 @@ jobs:
6582 echo "GITHUB_REF_NAME is: $GITHUB_REF_NAME"
6683 echo "github.event.pull_request.id is: ${{github.event.pull_request.id}}"
6784 echo "github.event.pull_request.html_url is: ${{github.event.pull_request.html_url}}"
68- echo "github.event.pull_request.number is: ${{github.event.pull_request.number}}"
85+ echo "github.event.pull_request.number is: ${{github.event.pull_request.number}}"
6986 echo "github.event.pull_request.url is: ${{github.event.pull_request.url}}"
7087 echo "github.event.pull_request.issue_url is: ${{github.event.pull_request.issue_url}}"
71- echo "github.event.pull_request.comments_url is: ${{github.event.pull_request.comments_url}}"
72- echo "github.event.pull_request.statuses_url is: ${{github.event.pull_request.statuses_url}}"
7388 echo "github.event.pull_request.head.sha is: ${{github.event.pull_request.head.sha}}"
7489 echo "github.event.pull_request.base.ref is: ${{github.event.pull_request.base.ref}}"
7590 echo "github.event.pull_request.merge_commit_sha is: ${{github.event.pull_request.merge_commit_sha}}"
7691 echo "github.event.pull_request is: ${{github.event.pull_request}}"
77- pip3 show python-jenkins || echo "python-jenkins is not installed"
78- #sudo -H pip3 install --upgrade python-jenkins
79- # pipeline name shuould be unique to the workfow yml for a given repository
80- #curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{'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'}}" ${{github.event.pull_request.comments_url}} -d '{"body":"Github action triggered jenkins job for compute-psdb-staging-smi-libs-ghemu "}'
92+
93+
8194 - name : Trigger Jenkins Pipeline
8295 if : steps.check_changes.outcome != 'failure'
8396 run : |
84- echo "running jenkins_api.py with input sha - $input_sha for pull request - $input_pr_url"
85- python3 jenkins_api.py -s $JENKINS_URL -jn $pipeline_name -ghr $GITHUB_REPOSITORY -ghsha $input_sha -ghprn $input_pr_num -ghpru "$input_pr_url" -ghprt "$input_pr_title" -ghpat $svc_acc_org_secret
97+ echo "--Running jenkins_api.py with input sha - $input_sha for pull request - $input_pr_url"
98+ docker exec -e GITHUB_REPOSITORY="$GITHUB_REPOSITORY" -e svc_acc_org_secret="$svc_acc_org_secret" -e input_sha="$input_sha" -e input_pr_url="$input_pr_url" -e pipeline_name="$pipeline_name" \
99+ -e input_pr_num="$input_pr_num" -e PR_TITLE="$PR_TITLE" -e JENKINS_URL="$JENKINS_URL" -e GITHUB_PAT="$svc_acc_org_secret" "${{env.CONTAINER_NAME}}" \
100+ /bin/bash -c 'echo \"PR NUM: "$input_pr_num"\" && PYTHONHTTPSVERIFY=0 python3 jenkins_api.py -s \"${JENKINS_URL}\" -jn "$pipeline_name" -ghr "$GITHUB_REPOSITORY" -ghsha "$input_sha" -ghprn "$input_pr_num" -ghpru "$input_pr_url" -ghprt "$PR_TITLE" -ghpat="$svc_acc_org_secret"'
101+
102+ - name : Stop and remove container
103+ if : always()
104+ run : |
105+ docker stop "${{env.CONTAINER_NAME}}"
106+ docker rm "${{env.CONTAINER_NAME}}"
0 commit comments