Skip to content

Commit 4377fb0

Browse files
committed
Swift: auto-install codeql on codespace
1 parent 400d7af commit 4377fb0

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

.devcontainer/swift/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-ubuntu-22.04
55

66
USER root
77
ADD root.sh /tmp/root.sh
8+
ADD update-codeql.sh /usr/local/bin/update-codeql
89
RUN bash /tmp/root.sh && rm /tmp/root.sh

.devcontainer/swift/root.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ curl -fSsL -o /usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk/rel
1717
echo "${BAZELISK_DOWNLOAD_SHA} */usr/local/bin/bazelisk" | sha256sum --check -
1818
chmod 0755 /usr/local/bin/bazelisk
1919
ln -s bazelisk /usr/local/bin/bazel
20+
21+
# install latest codeql
22+
update-codeql

.devcontainer/swift/update-codeql.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash -e
2+
3+
URL=https://github.com/github/codeql-cli-binaries/releases
4+
LATEST_VERSION=$(curl -L -s -H 'Accept: application/json' $URL/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
5+
CURRENT_VERSION=v$(codeql version 2>/dev/null | sed -ne 's/.*release \([0-9.]*\)\./\1/p')
6+
if [[ $CURRENT_VERSION != $LATEST_VERSION ]]; then
7+
curl -fSqL -o /tmp/codeql.zip $URL/download/$LATEST_VERSION/codeql-linux64.zip
8+
unzip /tmp/codeql.zip -qd /opt
9+
rm /tmp/codeql.zip
10+
ln -sf /opt/codeql/codeql /usr/local/bin/codeql
11+
echo installed version $LATEST_VERSION
12+
else
13+
echo current version $CURRENT_VERSION is up-to-date
14+
fi

.devcontainer/swift/user.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ bazel run swift/create-extractor-pack
1111
#install and set up pre-commit
1212
python3 -m pip install pre-commit --no-warn-script-location
1313
$HOME/.local/bin/pre-commit install
14-
15-
cat $(dirname $0)/user_bashrc.sh >> $HOME/.bashrc

.devcontainer/swift/user_bashrc.sh

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

0 commit comments

Comments
 (0)