Skip to content

Commit a76042a

Browse files
authored
Merge pull request #26 from github/integration-tests
Testing overhaul
2 parents c0d9de1 + 1477a43 commit a76042a

File tree

42 files changed

+432
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+432
-43
lines changed

.github/codeql/codeql-config.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
me: "CodeQL config"
1+
name: "CodeQL config"
22
queries:
33
- name: Run custom queries
44
uses: ./queries
5+
paths-ignore:
6+
- tests

.github/workflows/codeql.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ jobs:
1313
- uses: actions/checkout@v1
1414
- uses: ./init
1515
with:
16-
config-file: ./.github/codeql/codeql-config.yml
16+
languages: javascript
17+
config-file: ./.github/codeql/codeql-config.yml
1718
- uses: ./analyze
Lines changed: 110 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,117 @@
11
name: "Integration Testing"
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
6-
dispatch-events:
7-
if: github.event.repository.full_name == 'github/codeql-action'
6+
multi-language-repo_test-autodetect-languages:
7+
strategy:
8+
matrix:
9+
os: [ubuntu-latest, windows-latest, macos-latest]
10+
runs-on: ${{ matrix.os }}
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Move codeql-action
15+
shell: bash
16+
run: |
17+
mkdir ../action
18+
shopt -s dotglob
19+
mv * ../action/
20+
mv ../action/tests/multi-language-repo/* .
21+
- uses: ./../action/init
22+
- name: Build code
23+
shell: bash
24+
run: ./build.sh
25+
- uses: ./../action/analyze
26+
env:
27+
TEST_MODE: true
28+
29+
multi-language-repo_test-custom-queries:
30+
strategy:
31+
matrix:
32+
os: [ubuntu-latest, windows-latest, macos-latest]
33+
runs-on: ${{ matrix.os }}
34+
35+
steps:
36+
- uses: actions/checkout@v2
37+
- name: Move codeql-action
38+
shell: bash
39+
run: |
40+
mkdir ../action
41+
shopt -s dotglob
42+
mv * ../action/
43+
mv ../action/tests/multi-language-repo/* .
44+
- uses: ./../action/init
45+
with:
46+
languages: cpp,csharp,java,javascript,python
47+
config-file: ./.github/codeql/custom-queries.yml
48+
- name: Build code
49+
shell: bash
50+
run: ./build.sh
51+
- uses: ./../action/analyze
52+
env:
53+
TEST_MODE: true
54+
55+
# Currently is not possible to analyze Go in conjunction with other languages in macos
56+
multi-language-repo_test-go-custom-queries:
57+
strategy:
58+
matrix:
59+
os: [ubuntu-latest, windows-latest, macos-latest]
60+
runs-on: ${{ matrix.os }}
61+
62+
steps:
63+
- uses: actions/setup-go@v2
64+
if: ${{ matrix.os == 'macos-latest' }}
65+
with:
66+
go-version: '^1.13.1'
67+
- uses: actions/checkout@v2
68+
- name: Move codeql-action
69+
shell: bash
70+
run: |
71+
mkdir ../action
72+
shopt -s dotglob
73+
mv * ../action/
74+
mv ../action/tests/multi-language-repo/* .
75+
- uses: ./../action/init
76+
with:
77+
languages: go
78+
config-file: ./.github/codeql/custom-queries.yml
79+
- name: Build code
80+
shell: bash
81+
run: ./build.sh
82+
- uses: ./../action/analyze
83+
env:
84+
TEST_MODE: true
85+
86+
87+
multi-language-repo_rubocop:
888
runs-on: ubuntu-latest
89+
990
steps:
10-
- name: Send repository dispatch events
91+
- uses: actions/checkout@v2
92+
- name: Move codeql-action
93+
shell: bash
94+
run: |
95+
mkdir ../action
96+
shopt -s dotglob
97+
mv * ../action/
98+
mv ../action/tests/multi-language-repo/* .
99+
- name: Set up Ruby
100+
uses: ruby/setup-ruby@v1
101+
with:
102+
ruby-version: 2.6
103+
- name: Install Code Scanning integration
104+
run: bundle add code-scanning-rubocop --version 0.2.0 --skip-install
105+
- name: Install dependencies
106+
run: bundle install
107+
- name: Rubocop run
11108
run: |
12-
curl -X POST \
13-
-H "Authorization: Bearer ${{ secrets.CODEQL_TESTING_TOKEN }}" \
14-
-H "Accept: application/vnd.github.everest-preview+json" \
15-
https://api.github.com/repos/Anthophila/amazon-cognito-js-copy/dispatches \
16-
-d '{"event_type":"codeql-integration","client_payload": {"sha": "${{ github.sha }}"}}'
17-
18-
curl -X POST \
19-
-H "Authorization: Bearer ${{ secrets.CODEQL_TESTING_TOKEN }}" \
20-
-H "Accept: application/vnd.github.everest-preview+json" \
21-
https://api.github.com/repos/Anthophila/electron-test-action/dispatches \
22-
-d '{"event_type":"codeql-integration","client_payload": {"sha": "${{ github.sha }}"}}'
109+
bash -c "
110+
bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
111+
[[ $? -ne 2 ]]
112+
"
113+
- uses: ./../action/upload-sarif
114+
with:
115+
sarif_file: rubocop.sarif
116+
env:
117+
TEST_MODE: true

.github/workflows/js-uptodate-check.yml renamed to .github/workflows/lint-build-test.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
name: "Check generated JavaScript"
1+
name: "Lint, Build & Test"
22

3-
on: [pull_request]
3+
on: [push, pull_request]
44

55
jobs:
6+
tslint:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v1
11+
- name: tslint
12+
run: npm run-script lint
13+
614
check-js:
715
runs-on: ubuntu-latest
816

@@ -25,3 +33,11 @@ jobs:
2533
exit 1
2634
fi
2735
echo "Success: JavaScript files are up to date"
36+
37+
npm-test:
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- uses: actions/checkout@v1
42+
- name: npm run-script test
43+
run: npm run-script test

.github/workflows/npm-test.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/ts-lint.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

lib/upload-lib.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/upload-lib.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ export function combineSarifFiles(sarifFiles: string[]): string {
5252
async function uploadPayload(payload): Promise<boolean> {
5353
core.info('Uploading results');
5454

55+
// If in test mode we don't want to upload the results
56+
const testMode = process.env['TEST_MODE'] === 'true' || false;
57+
if (testMode) {
58+
return true;
59+
}
60+
5561
const githubToken = core.getInput('token');
5662
const ph: auth.BearerCredentialHandler = new auth.BearerCredentialHandler(githubToken);
5763
const client = new http.HttpClient('Code Scanning : Upload SARIF', [ph]);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Use custom queries
2+
3+
disable-default-queries: true
4+
5+
queries:
6+
# Query suites
7+
- name: Select a query suite
8+
uses: ./codeql-qlpacks/complex-python-qlpack/rootAndBar.qls
9+
# QL pack subset
10+
- name: Select a ql file
11+
uses: ./codeql-qlpacks/complex-javascript-qlpack/show_ifs.ql
12+
- name: Select a subfolder
13+
uses: ./codeql-qlpacks/complex-javascript-qlpack/foo
14+
- name: Select a folder with two subfolders
15+
uses: ./codeql-qlpacks/complex-javascript-qlpack/foo2
16+
# Inrepo QL pack
17+
- name: Select an inrepo ql pack
18+
uses: ./codeql-qlpacks/csharp-qlpack
19+
- name: Java queries
20+
uses: ./codeql-qlpacks/java-qlpack
21+
# External QL packs
22+
- name: Go queries
23+
uses: Anthophila/go-querypack@master
24+
- name: Cpp queries
25+
uses: Anthophila/cpp-querypack@second-branch
26+
- name: Javascript queries
27+
uses: Anthophila/javascript-querypack/show_ifs2.ql@master
28+
- name: Python queries
29+
uses: Anthophila/python-querypack/show_ifs2.ql@second-branch

tests/multi-language-repo/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source "https://rubygems.org" do
2+
end

0 commit comments

Comments
 (0)