Skip to content

Commit

Permalink
Swift: auto-install codeql on codespace
Browse files Browse the repository at this point in the history
  • Loading branch information
redsun82 committed Jun 22, 2022
1 parent 400d7af commit 4377fb0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions .devcontainer/swift/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-ubuntu-22.04

USER root
ADD root.sh /tmp/root.sh
ADD update-codeql.sh /usr/local/bin/update-codeql
RUN bash /tmp/root.sh && rm /tmp/root.sh
3 changes: 3 additions & 0 deletions .devcontainer/swift/root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ curl -fSsL -o /usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk/rel
echo "${BAZELISK_DOWNLOAD_SHA} */usr/local/bin/bazelisk" | sha256sum --check -
chmod 0755 /usr/local/bin/bazelisk
ln -s bazelisk /usr/local/bin/bazel

# install latest codeql
update-codeql
14 changes: 14 additions & 0 deletions .devcontainer/swift/update-codeql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -e

URL=https://github.com/github/codeql-cli-binaries/releases
LATEST_VERSION=$(curl -L -s -H 'Accept: application/json' $URL/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
CURRENT_VERSION=v$(codeql version 2>/dev/null | sed -ne 's/.*release \([0-9.]*\)\./\1/p')
if [[ $CURRENT_VERSION != $LATEST_VERSION ]]; then
curl -fSqL -o /tmp/codeql.zip $URL/download/$LATEST_VERSION/codeql-linux64.zip
unzip /tmp/codeql.zip -qd /opt
rm /tmp/codeql.zip
ln -sf /opt/codeql/codeql /usr/local/bin/codeql
echo installed version $LATEST_VERSION
else
echo current version $CURRENT_VERSION is up-to-date
fi
2 changes: 0 additions & 2 deletions .devcontainer/swift/user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ bazel run swift/create-extractor-pack
#install and set up pre-commit
python3 -m pip install pre-commit --no-warn-script-location
$HOME/.local/bin/pre-commit install

cat $(dirname $0)/user_bashrc.sh >> $HOME/.bashrc
5 changes: 0 additions & 5 deletions .devcontainer/swift/user_bashrc.sh

This file was deleted.

0 comments on commit 4377fb0

Please sign in to comment.