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 amd-mainline PSDB trigger
1
+ # This workflow is used to invoke the PSDB jenkins job for rocm 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 on amd-mainline branch
3
3
4
4
# Controls when the workflow will run
5
5
on :
@@ -13,43 +13,53 @@ jobs:
13
13
# This workflow contains a single job called "build"
14
14
invoke_jenkins_PSDB :
15
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
16
+ # runs-on: ubuntu-latest
17
17
if : github.event.pull_request.draft == false
18
18
runs-on : self-hosted
19
- container :
20
- image : compute-artifactory.amd.com:5000/rocm-base-images/ghemu-action-ubuntu-24.04:2024101101
21
19
env :
22
- svc_acc_org_secret : ${{'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' }}
20
+ svc_acc_org_secret : ${{secrets.CI_GITHUB_TOKEN }}
23
21
input_sha : ${{ github.event.pull_request.head.sha != '' && github.event.pull_request.head.sha || github.sha }}
24
22
input_pr_num : ${{ github.event.pull_request.number != '' && github.event.pull_request.number || 0 }}
25
23
input_pr_url : ${{ github.event.pull_request.html_url != '' && github.event.pull_request.html_url || '' }}
26
24
input_pr_title : ${{ github.event.pull_request.title != '' && github.event.pull_request.title || '' }}
27
25
# set the pipeline name here based on branch name
28
- pipeline_name : ${{ 'compiler-psdb-amd-mainline' }}
29
- JENKINS_URL : ${{'https://compiler-ci.amd.com/'}}
26
+ pipeline_name : ${{secrets.CI_JENKINS_JOB_NAME}}
27
+ JENKINS_URL : ${{secrets.CI_JENKINS_URL}}
28
+ CONTAINER_IMAGE : ${{ secrets.JENKINS_TRIGGER_DOCKER_IMAGE }}
29
+
30
30
# 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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'}}
31
+ steps :
41
32
33
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
34
+ - name : Set environment variable for container image
35
+ run : |
36
+ echo "CONTAINER_IMAGE=${{ secrets.JENKINS_TRIGGER_DOCKER_IMAGE }}" >> $GITHUB_ENV
37
+ echo "CONTAINER_NAME=my_container_${{ github.run_id }}" >> $GITHUB_ENV
38
+ - name : Print environment variables
39
+ run : |
40
+ echo "CONTAINER_IMAGE=${{ env.CONTAINER_IMAGE }}"
41
+ echo "CONTAINER_NAME=${{ env.CONTAINER_NAME }}"
42
42
43
+ - name : Pull container image
44
+ run : docker pull "${{env.CONTAINER_IMAGE}}"
45
+
46
+
47
+ - name : Run container
48
+ run : |
49
+ docker run -d --name "${{env.CONTAINER_NAME}}" $CONTAINER_IMAGE sleep infinity
50
+ #docker exec "${{env.CONTAINER_NAME}}" /bin/bash -c "git clone ${{secrets.CI_UTILS_REPO}} ."
51
+ docker exec "${{env.CONTAINER_NAME}}" /bin/bash -c "echo 'Running commands inside the container'"
52
+
43
53
- name : Run Jenkins Cancel Script
44
54
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' }}
55
+ JENKINS_URL : ${{secrets.CI_JENKINS_URL }}
56
+ JENKINS_USER : ${{secrets.CI_JENKINS_USER }}
57
+ JENKINS_API_TOKEN : ${{secrets.CI_JENKINS_TOKEN }}
58
+ JENKINS_JOB_NAME : ${{secrets.CI_JENKINS_JOB_NAME }}
49
59
PR_NUMBER : ${{ github.event.pull_request.number }}
50
60
COMMIT_HASH : ${{ github.event.after }}
51
61
run : |
52
- python3 cancel_previous_build.py
62
+ 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 " python3 cancel_previous_build.py"
53
63
54
64
55
65
# Runs a set of commands using the runners shell
66
76
echo "github.event.pull_request.id is: ${{github.event.pull_request.id}}"
67
77
echo "github.event.pull_request.html_url is: ${{github.event.pull_request.html_url}}"
68
78
echo "github.event.pull_request.number is: ${{github.event.pull_request.number}}"
79
+ echo "github.event.pull_request.title is: ${{github.event.pull_request.title}}"
69
80
echo "github.event.pull_request.url is: ${{github.event.pull_request.url}}"
70
81
echo "github.event.pull_request.issue_url is: ${{github.event.pull_request.issue_url}}"
71
82
echo "github.event.pull_request.comments_url is: ${{github.event.pull_request.comments_url}}"
77
88
pip3 show python-jenkins || echo "python-jenkins is not installed"
78
89
#sudo -H pip3 install --upgrade python-jenkins
79
90
# 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 "}'
91
+ #curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{secrets.CI_GITHUB_TOKEN}}" ${{github.event.pull_request.comments_url}} -d '{"body":"Github action triggered jenkins job for compute-psdb-staging-smi-libs-ghemu "}'
92
+ #python jenkins_api.py -jn compute-psdb-staging-smi-libs-ghemu -ghr $GITHUB_REPOSITORY -ghsha $input_sha -ghprn $input_pr_num -ghpru "$input_pr_url" -ghprt "$input_pr_title"
81
93
- name : Trigger Jenkins Pipeline
82
94
if : steps.check_changes.outcome != 'failure'
83
95
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
96
+ echo "--Running jenkins_api.py with input sha - $input_sha for pull request - $input_pr_url"
97
+ docker exec -e JENKINS_URL=${{secrets.CI_JENKINS_URL}} -e GITHUB_PAT=${{secrets.CI_GITHUB_TOKEN}} "${{env.CONTAINER_NAME}}" /bin/bash -c "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}\""
98
+ - name : Stop and remove container
99
+ if : always()
100
+ run : |
101
+ docker stop "${{env.CONTAINER_NAME}}"
102
+ docker rm "${{env.CONTAINER_NAME}}"
0 commit comments