@@ -38,63 +38,4 @@ describe('helper', () => {
3838 expect ( helper . getSizeOfJsonObjectInBytes ( truncatedVCSInfo ) ) . to . be . lessThanOrEqual ( 64 * 1024 ) ;
3939 } ) ;
4040 } ) ;
41-
42- describe ( 'getCiInfo' , ( ) => {
43- const CI_VARS = [ 'CI' , 'GITHUB_ACTIONS' , 'GITHUB_SERVER_URL' , 'GITHUB_REPOSITORY' , 'GITHUB_RUN_ID' , 'GITHUB_RUN_NUMBER' , 'GITHUB_WORKFLOW' , 'GITHUB_JOB' , 'JENKINS_URL' , 'JENKINS_HOME' , 'BUILD_URL' , 'JOB_NAME' , 'BUILD_NUMBER' ] ;
44- let savedEnv = { } ;
45-
46- beforeEach ( ( ) => {
47- CI_VARS . forEach ( ( k ) => {
48- savedEnv [ k ] = process . env [ k ] ;
49- delete process . env [ k ] ;
50- } ) ;
51- } ) ;
52-
53- afterEach ( ( ) => {
54- CI_VARS . forEach ( ( k ) => {
55- if ( savedEnv [ k ] === undefined ) delete process . env [ k ] ;
56- else process . env [ k ] = savedEnv [ k ] ;
57- } ) ;
58- savedEnv = { } ;
59- } ) ;
60-
61- const setGithubActionsEnv = ( ) => {
62- process . env . CI = 'true' ;
63- process . env . GITHUB_ACTIONS = 'true' ;
64- process . env . GITHUB_SERVER_URL = 'https://github.com' ;
65- process . env . GITHUB_REPOSITORY = 'org/repo' ;
66- process . env . GITHUB_RUN_ID = '27412345678' ;
67- process . env . GITHUB_WORKFLOW = 'CI Workflow' ;
68- } ;
69-
70- it ( 'detects GitHub Actions with build_url and run-id build_number' , ( ) => {
71- setGithubActionsEnv ( ) ;
72- const ciInfo = helper . getCiInfo ( ) ;
73- expect ( ciInfo . name ) . to . eq ( 'GitHub Actions' ) ;
74- expect ( ciInfo . build_url ) . to . eq ( 'https://github.com/org/repo/actions/runs/27412345678' ) ;
75- expect ( ciInfo . build_number ) . to . eq ( '27412345678' ) ;
76- } ) ;
77-
78- it ( 'prefers GitHub Actions over leaked Jenkins env vars on self-hosted runners' , ( ) => {
79- setGithubActionsEnv ( ) ;
80- process . env . JENKINS_HOME = '/var/lib/jenkins' ;
81- const ciInfo = helper . getCiInfo ( ) ;
82- expect ( ciInfo . name ) . to . eq ( 'GitHub Actions' ) ;
83- expect ( ciInfo . build_url ) . to . eq ( 'https://github.com/org/repo/actions/runs/27412345678' ) ;
84- } ) ;
85-
86- it ( 'detects Jenkins when no explicit CI marker is set' , ( ) => {
87- process . env . JENKINS_URL = 'https://ci.internal/job/x' ;
88- process . env . BUILD_URL = 'https://ci.internal/job/x/42/' ;
89- process . env . JOB_NAME = 'x' ;
90- process . env . BUILD_NUMBER = '42' ;
91- const ciInfo = helper . getCiInfo ( ) ;
92- expect ( ciInfo . name ) . to . eq ( 'Jenkins' ) ;
93- expect ( ciInfo . build_url ) . to . eq ( 'https://ci.internal/job/x/42/' ) ;
94- } ) ;
95-
96- it ( 'returns null when no CI is detected' , ( ) => {
97- expect ( helper . getCiInfo ( ) ) . to . be . null ;
98- } ) ;
99- } ) ;
10041} ) ;
0 commit comments