Skip to content

Commit 1fc18d7

Browse files
authored
Merge pull request #2 from Perdiga/feat/codeql
Feat/codeql
2 parents 2716b66 + a2fc7f3 commit 1fc18d7

File tree

4 files changed

+30
-38
lines changed

4 files changed

+30
-38
lines changed

src/codeql/devcontainer-feature.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"codeql_version": {
88
"type": "string",
99
"proposals": [
10-
"2.19.1"
10+
"latest"
1111
],
12-
"default": "2.19.1",
12+
"default": "latest",
1313
"description": "Select the version of the CodeQL CLI to install"
1414
}
1515
},

src/codeql/install.sh

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
CODEQL_HOME=/usr/local/codeql-home
5-
5+
CODEQL_TAG=""
66
echo "Activating feature 'CodeQL'"
77
echo "The provided CodeQL version is: $CODEQL_VERSION"
88
echo "The CodeQL home directory is: $CODEQL_HOME"
@@ -19,59 +19,52 @@ echo "The effective dev container remoteUser's home directory is '$_REMOTE_USER_
1919
echo "The effective dev container containerUser is '$_CONTAINER_USER'"
2020
echo "The effective dev container containerUser's home directory is '$_CONTAINER_USER_HOME'"
2121

22+
2223
check_version() {
23-
if [ -z "$1" ]; then
24-
echo "Version is not provided"
25-
exit 1
26-
fi
24+
echo "Checking version"
2725

28-
if ! [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
29-
echo "Version is not valid. Please provide a valid version"
30-
exit 1
26+
# Set the codeql version to the latest if it is not provided
27+
if [ "$CODEQL_VERSION" = "latest" ]; then
28+
CODEQL_TAG=$(curl -s https://api.github.com/repos/github/codeql-action/releases/latest | jq -r '.tag_name')
29+
echo "Setting the CodeQL version to the latest: $CODEQL_TAG"
30+
else
31+
CODEQL_TAG="codeql-bundle-v$CODEQL_VERSION"
32+
echo "Using provided version: $CODEQL_TAG"
3133
fi
3234
}
3335

34-
install_packages(){
36+
install_packages() {
37+
echo "Installing required packages"
38+
3539
apt-get update && \
3640
apt-get upgrade -y && \
3741
apt-get install -y --no-install-recommends \
38-
software-properties-common \
3942
curl \
40-
git \
41-
git-lfs \
42-
build-essential \
43-
unzip \
44-
apt-transport-https \
45-
python3.10 \
46-
python3-venv \
47-
python3-pip \
48-
python3-setuptools \
49-
python3-dev \
50-
python-is-python3 \
51-
gnupg \
52-
g++ \
53-
make \
54-
gcc \
55-
apt-utils
56-
57-
# Clean up
58-
apt-get clean && apt-get autoremove
43+
jq \
44+
ca-certificates
45+
46+
update-ca-certificates
47+
48+
echo "Installed packages:"
49+
curl --version
50+
jq --version
5951
}
6052

61-
install_codeql(){
53+
install_codeql() {
54+
echo "Installing CodeQL"
6255
mkdir ${CODEQL_HOME}
6356

6457
# Install CodeQL
6558
cd /tmp
6659

67-
echo "Downloading CodeQL bundle v${CODEQL_VERSION}"
68-
curl -OL https://github.com/github/codeql-action/releases/download/codeql-bundle-v${CODEQL_VERSION}/codeql-bundle-linux64.tar.gz
60+
echo "Downloading CodeQL bundle v${CODEQL_TAG}"
61+
curl -OL https://github.com/github/codeql-action/releases/download/${CODEQL_TAG}/codeql-bundle-linux64.tar.gz
6962
tar -xvf /tmp/codeql-bundle-linux64.tar.gz --directory ${CODEQL_HOME}
7063
rm /tmp/codeql-bundle-linux64.tar.gz
7164
}
7265

73-
check_version
66+
install_packages
7467

75-
#install_packages
68+
check_version
7669

7770
install_codeql

test/codeql/codeql_version.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ source dev-container-features-test-lib
1010

1111
# Feature-specific tests
1212
# The 'check' command comes from the dev-container-features-test-lib.
13-
check "execute command" bash -c "color | grep 'CodeQL installed at /usr/local/codeql-home and version is 2.19.1"
1413
check "Validate CodeQL Version installed" codeql --version | grep "$CODEQL_VERSION"
1514

1615
# Report result

test/codeql/scenarios.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"check_codeql_version": {
2+
"codeql_version": {
33
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
44
"features": {
55
"codeql": {

0 commit comments

Comments
 (0)