@@ -2,6 +2,7 @@ import test from "ava";
22
33import {
44 getDraftStateFromContext ,
5+ getPullRequestCommitShas ,
56 shouldSkipDraftAnalysis ,
67 shouldSkipUnchangedLanguage ,
78} from "./analysis-skip" ;
@@ -24,11 +25,13 @@ test("draft state can be supplied by a pull_request or dynamic event", (t) => {
2425 t . is ( getDraftStateFromContext ( undefined ) , undefined ) ;
2526} ) ;
2627
27- test ( "JavaScript changes do not start an unchanged Python analysis" , ( t ) => {
28- const files = [ ".github/issue-triage/guard.mjs" , "docs/setup.md" ] ;
29-
30- t . false ( shouldSkipUnchangedLanguage ( true , "javascript-typescript" , files ) ) ;
31- t . true ( shouldSkipUnchangedLanguage ( true , "python" , files ) ) ;
28+ test ( "source changes in another language fail open" , ( t ) => {
29+ t . false (
30+ shouldSkipUnchangedLanguage ( true , "python" , [
31+ ".github/issue-triage/guard.mjs" ,
32+ "docs/setup.md" ,
33+ ] ) ,
34+ ) ;
3235} ) ;
3336
3437test ( "documentation-only changes can skip a language analysis" , ( t ) => {
@@ -49,14 +52,35 @@ test("language-specific dependency files keep their language analysis", (t) => {
4952 t . false (
5053 shouldSkipUnchangedLanguage ( true , "python" , [ "requirements-dev.txt" ] ) ,
5154 ) ;
55+ t . false ( shouldSkipUnchangedLanguage ( true , "cpp" , [ "CMakeLists.txt" ] ) ) ;
5256} ) ;
5357
54- test ( "build scripts are ignored only when the workflow uses build-mode none" , ( t ) => {
55- const files = [ "src/guard.mjs" , "scripts/test-issue-triage.sh" ] ;
58+ test ( "build scripts always keep the analysis enabled" , ( t ) => {
59+ t . false (
60+ shouldSkipUnchangedLanguage ( true , "python" , [
61+ "scripts/test-issue-triage.sh" ,
62+ ] ) ,
63+ ) ;
64+ } ) ;
65+
66+ test ( "workflow changes are relevant to every language" , ( t ) => {
67+ t . false (
68+ shouldSkipUnchangedLanguage ( true , "python" , [
69+ ".github/workflows/codeql.yml" ,
70+ ] ) ,
71+ ) ;
72+ } ) ;
5673
57- t . true ( shouldSkipUnchangedLanguage ( true , "python" , files , "none" ) ) ;
58- t . false ( shouldSkipUnchangedLanguage ( true , "python" , files , "manual" ) ) ;
59- t . false ( shouldSkipUnchangedLanguage ( true , "python" , files ) ) ;
74+ test ( "pull-request diffs use immutable event commit SHAs" , ( t ) => {
75+ t . deepEqual (
76+ getPullRequestCommitShas ( {
77+ base : { sha : "base-sha" } ,
78+ head : { sha : "head-sha" } ,
79+ } ) ,
80+ { base : "base-sha" , head : "head-sha" } ,
81+ ) ;
82+ t . is ( getPullRequestCommitShas ( { base : { sha : "base-sha" } } ) , undefined ) ;
83+ t . is ( getPullRequestCommitShas ( undefined ) , undefined ) ;
6084} ) ;
6185
6286test ( "renames are relevant to both the old and new languages" , ( t ) => {
@@ -77,6 +101,8 @@ test("unknown and CodeQL configuration paths fail open", (t) => {
77101 ".github/codeql/codeql-config.yml" ,
78102 ] ) ,
79103 ) ;
104+ t . false ( shouldSkipUnchangedLanguage ( true , "cpp" , [ "meson_options.txt" ] ) ) ;
105+ t . false ( shouldSkipUnchangedLanguage ( true , "python" , [ "conanfile.txt" ] ) ) ;
80106} ) ;
81107
82108test ( "incomplete inputs, multi-language jobs, and disabled gates fail open" , ( t ) => {
0 commit comments