Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d71110

Browse files
authored
Merge pull request #2 from github/edoardo/add-ci
Add some basic CI checks
2 parents 0c76ae1 + 44809e1 commit 4d71110

4 files changed

Lines changed: 82 additions & 0 deletions

File tree

.github/workflows/pr-checks.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: PR Checks
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
pr-checks:
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, macos-latest, windows-latest]
14+
name: PR Checks
15+
runs-on: ${{ matrix.os }}
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
22+
- name: Install extension
23+
shell: bash
24+
run: |
25+
gh extensions install .
26+
27+
- name: Check basic functionality
28+
working-directory: test-resources
29+
shell: bash
30+
run: |
31+
gh codeql database create -l cpp -s test-repo -c "gcc -o main main.c" test-db
32+
gh codeql pack install test-pack
33+
gh codeql database analyze --format=sarif-latest --output=out.sarif test-db test-pack/allExpressions.ql
34+
RESULTS=`jq '.runs[0].results | length' out.sarif`
35+
if [[ $RESULTS != 1 ]]; then
36+
echo "::error::Invalid number of results from test query, expected 1 but got $RESULTS"
37+
exit 1
38+
fi
39+
40+
- name: Check version pinning
41+
shell: bash
42+
run: |
43+
gh codeql set-version v2.5.9
44+
VERSION=`gh codeql version --format json | jq -r '.version'`
45+
if [[ $VERSION != "2.5.9" ]]; then
46+
echo "::error::Expected version 2.5.9 but got $VERSION"
47+
exit 1
48+
fi
49+
50+
- name: Check version unpinning
51+
shell: bash
52+
run: |
53+
gh codeql set-version latest
54+
VERSION=`gh codeql version --format json | jq -r '.version'`
55+
if [[ $VERSION == "2.5.9" ]]; then
56+
echo "::error::Expected latest version but got 2.5.9"
57+
exit 1
58+
fi
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @id cpp/all-exprs
3+
* @name All expressions
4+
* @description Finds all expressions
5+
* @kind problem
6+
* @problem.severity warning
7+
*/
8+
9+
import cpp
10+
11+
from ExprStmt s
12+
select s, "Is an expression"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: test-cpp-querypack
2+
version: 0.0.1
3+
dependencies:
4+
codeql/cpp-all: "*"

test-resources/test-repo/main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "stdio.h"
2+
3+
int main(int argc, char **argv) {
4+
if (1) {
5+
printf("Hello, World!\n");
6+
}
7+
}
8+

0 commit comments

Comments
 (0)