Skip to content

Commit 1f0700d

Browse files
Update unset environment variables PR check (#1269)
* Only test Java for CLI v2.5+ * Improve bash code style * Set Actions error messages Co-authored-by: Andrew Eisenberg <[email protected]>
1 parent 314ede6 commit 1f0700d

File tree

4 files changed

+184
-146
lines changed

4 files changed

+184
-146
lines changed

.github/workflows/__unset-environment.yml

Lines changed: 0 additions & 97 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# See `unset-environment-old-cli.yml` for reasoning behind the separate tests.
2+
name: PR Check - Test unsetting environment variables for CLI version >= 2.5.1
3+
env:
4+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5+
GO111MODULE: auto
6+
on:
7+
push:
8+
branches:
9+
- main
10+
- releases/v1
11+
- releases/v2
12+
pull_request:
13+
types:
14+
- opened
15+
- synchronize
16+
- reopened
17+
- ready_for_review
18+
workflow_dispatch: {}
19+
jobs:
20+
unset-environment:
21+
strategy:
22+
matrix:
23+
include:
24+
- os: ubuntu-latest
25+
version: stable-20210809
26+
- os: ubuntu-latest
27+
version: cached
28+
- os: ubuntu-latest
29+
version: latest
30+
- os: ubuntu-latest
31+
version: nightly-latest
32+
name: Test unsetting environment variables
33+
timeout-minutes: 45
34+
runs-on: ${{ matrix.os }}
35+
steps:
36+
- name: Check out repository
37+
uses: actions/checkout@v3
38+
- name: Prepare test
39+
id: prepare-test
40+
uses: ./.github/prepare-test
41+
with:
42+
version: ${{ matrix.version }}
43+
- uses: ./../action/init
44+
with:
45+
db-location: ${{ runner.temp }}/customDbLocation
46+
tools: ${{ steps.prepare-test.outputs.tools-url }}
47+
env:
48+
TEST_MODE: true
49+
- name: Build code
50+
shell: bash
51+
run: env -i PATH="$PATH" HOME="$HOME" ./build.sh
52+
- uses: ./../action/analyze
53+
id: analysis
54+
env:
55+
TEST_MODE: true
56+
- shell: bash
57+
run: |
58+
CPP_DB="${{ fromJson(steps.analysis.outputs.db-locations).cpp }}"
59+
if [[ ! -d "$CPP_DB" ]] || [[ ! "$CPP_DB" == "${RUNNER_TEMP}/customDbLocation/cpp" ]]; then
60+
echo "::error::Did not create a database for CPP, or created it in the wrong location." \
61+
"Expected location was '${RUNNER_TEMP}/customDbLocation/cpp' but actual was '${CPP_DB}'"
62+
exit 1
63+
fi
64+
CSHARP_DB="${{ fromJson(steps.analysis.outputs.db-locations).csharp }}"
65+
if [[ ! -d "$CSHARP_DB" ]] || [[ ! "$CSHARP_DB" == "${RUNNER_TEMP}/customDbLocation/csharp" ]]; then
66+
echo "::error::Did not create a database for C Sharp, or created it in the wrong location." \
67+
"Expected location was '${RUNNER_TEMP}/customDbLocation/csharp' but actual was '${CSHARP_DB}'"
68+
exit 1
69+
fi
70+
GO_DB="${{ fromJson(steps.analysis.outputs.db-locations).go }}"
71+
if [[ ! -d "$GO_DB" ]] || [[ ! "$GO_DB" == "${RUNNER_TEMP}/customDbLocation/go" ]]; then
72+
echo "::error::Did not create a database for Go, or created it in the wrong location." \
73+
"Expected location was '${RUNNER_TEMP}/customDbLocation/go' but actual was '${GO_DB}'"
74+
exit 1
75+
fi
76+
JAVA_DB="${{ fromJson(steps.analysis.outputs.db-locations).java }}"
77+
if [[ ! -d "$JAVA_DB" ]] || [[ ! "$JAVA_DB" == "${RUNNER_TEMP}/customDbLocation/java" ]]; then
78+
echo "::error::Did not create a database for Java, or created it in the wrong location." \
79+
"Expected location was '${RUNNER_TEMP}/customDbLocation/java' but actual was '${JAVA_DB}'"
80+
exit 1
81+
fi
82+
JAVASCRIPT_DB="${{ fromJson(steps.analysis.outputs.db-locations).javascript }}"
83+
if [[ ! -d "$JAVASCRIPT_DB" ]] || [[ ! "$JAVASCRIPT_DB" == "${RUNNER_TEMP}/customDbLocation/javascript" ]]; then
84+
echo "::error::Did not create a database for Javascript, or created it in the wrong location." \
85+
"Expected location was '${RUNNER_TEMP}/customDbLocation/javascript' but actual was '${JAVASCRIPT_DB}'"
86+
exit 1
87+
fi
88+
PYTHON_DB="${{ fromJson(steps.analysis.outputs.db-locations).python }}"
89+
if [[ ! -d "$PYTHON_DB" ]] || [[ ! "$PYTHON_DB" == "${RUNNER_TEMP}/customDbLocation/python" ]]; then
90+
echo "::error::Did not create a database for Python, or created it in the wrong location." \
91+
"Expected location was '${RUNNER_TEMP}/customDbLocation/python' but actual was '${PYTHON_DB}'"
92+
exit 1
93+
fi
94+
env:
95+
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# There was a bug, fixed in CLI v2.5.1, that didn't propagate environment
2+
# variables that the Java tracer needed. Here we test all languages
3+
# except Java for these CLI versions. In `unset-environment-new-cli.yml`
4+
# we test all languages for recent CLI versions.
5+
name: PR Check - Test unsetting environment variables for CLI version < 2.5.1
6+
env:
7+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8+
GO111MODULE: auto
9+
on:
10+
push:
11+
branches:
12+
- main
13+
- releases/v1
14+
- releases/v2
15+
pull_request:
16+
types:
17+
- opened
18+
- synchronize
19+
- reopened
20+
- ready_for_review
21+
workflow_dispatch: {}
22+
jobs:
23+
unset-environment:
24+
strategy:
25+
matrix:
26+
include:
27+
- os: ubuntu-latest
28+
version: stable-20210308
29+
- os: ubuntu-latest
30+
version: stable-20210319
31+
name: Test unsetting environment variables
32+
timeout-minutes: 45
33+
runs-on: ${{ matrix.os }}
34+
steps:
35+
- name: Check out repository
36+
uses: actions/checkout@v3
37+
- name: Prepare test
38+
id: prepare-test
39+
uses: ./.github/prepare-test
40+
with:
41+
version: ${{ matrix.version }}
42+
- uses: ./../action/init
43+
with:
44+
languages: csharp,cpp,go,javascript,python
45+
db-location: ${{ runner.temp }}/customDbLocation
46+
tools: ${{ steps.prepare-test.outputs.tools-url }}
47+
env:
48+
TEST_MODE: true
49+
- name: Build code
50+
shell: bash
51+
run: env -i PATH="$PATH" HOME="$HOME" ./build.sh
52+
- uses: ./../action/analyze
53+
id: analysis
54+
env:
55+
TEST_MODE: true
56+
- shell: bash
57+
run: |
58+
CPP_DB="${{ fromJson(steps.analysis.outputs.db-locations).cpp }}"
59+
if [[ ! -d "$CPP_DB" ]] || [[ ! "$CPP_DB" == "${RUNNER_TEMP}/customDbLocation/cpp" ]]; then
60+
echo "::error::Did not create a database for CPP, or created it in the wrong location." \
61+
"Expected location was '${RUNNER_TEMP}/customDbLocation/cpp' but actual was '${CPP_DB}'"
62+
exit 1
63+
fi
64+
CSHARP_DB="${{ fromJson(steps.analysis.outputs.db-locations).csharp }}"
65+
if [[ ! -d "$CSHARP_DB" ]] || [[ ! "$CSHARP_DB" == "${RUNNER_TEMP}/customDbLocation/csharp" ]]; then
66+
echo "::error::Did not create a database for C Sharp, or created it in the wrong location." \
67+
"Expected location was '${RUNNER_TEMP}/customDbLocation/csharp' but actual was '${CSHARP_DB}'"
68+
exit 1
69+
fi
70+
GO_DB="${{ fromJson(steps.analysis.outputs.db-locations).go }}"
71+
if [[ ! -d "$GO_DB" ]] || [[ ! "$GO_DB" == "${RUNNER_TEMP}/customDbLocation/go" ]]; then
72+
echo "::error::Did not create a database for Go, or created it in the wrong location." \
73+
"Expected location was '${RUNNER_TEMP}/customDbLocation/go' but actual was '${GO_DB}'"
74+
exit 1
75+
fi
76+
JAVASCRIPT_DB="${{ fromJson(steps.analysis.outputs.db-locations).javascript }}"
77+
if [[ ! -d "$JAVASCRIPT_DB" ]] || [[ ! "$JAVASCRIPT_DB" == "${RUNNER_TEMP}/customDbLocation/javascript" ]]; then
78+
echo "::error::Did not create a database for Javascript, or created it in the wrong location." \
79+
"Expected location was '${RUNNER_TEMP}/customDbLocation/javascript' but actual was '${JAVASCRIPT_DB}'"
80+
exit 1
81+
fi
82+
PYTHON_DB="${{ fromJson(steps.analysis.outputs.db-locations).python }}"
83+
if [[ ! -d "$PYTHON_DB" ]] || [[ ! "$PYTHON_DB" == "${RUNNER_TEMP}/customDbLocation/python" ]]; then
84+
echo "::error::Did not create a database for Python, or created it in the wrong location." \
85+
"Expected location was '${RUNNER_TEMP}/customDbLocation/python' but actual was '${PYTHON_DB}'"
86+
exit 1
87+
fi
88+
env:
89+
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true

pr-checks/checks/unset-environment.yml

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

0 commit comments

Comments
 (0)