From 1dbe90802481d2281f37f987f335143238971412 Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Tue, 9 Jul 2024 10:48:18 +0200 Subject: [PATCH 1/2] Swift: tentative fix to install git-lfs in codespace without direct write access --- .devcontainer/swift/user.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.devcontainer/swift/user.sh b/.devcontainer/swift/user.sh index 1de3485a723b..568fdecbfcfe 100755 --- a/.devcontainer/swift/user.sh +++ b/.devcontainer/swift/user.sh @@ -1,6 +1,15 @@ set -xe -git lfs install +# git lfs install may fail because codespaces can install its own hooks +# let's install it manually +for script in pre-push post-checkout post-commit post-merge; do + if [ -x .git/hooks/$script ]; then + sed -i "2i git lfs $script || exit 1" .git/hooks/$script + else + printf "#!/bin/bash\ngit lfs %s\n" $script > .git/hooks/$script + chmod +x .git/hooks/$script + fi +done # add the workspace to the codeql search path mkdir -p /home/vscode/.config/codeql From bd1f548fbc280c3ee249302026b37eeb685e702a Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Tue, 16 Jul 2024 11:24:01 +0200 Subject: [PATCH 2/2] Swift: use `git-lfs` devcontainer feature --- .devcontainer/swift/devcontainer.json | 49 ++++++++++++++------------- .devcontainer/swift/root.sh | 4 --- .devcontainer/swift/user.sh | 11 ------ 3 files changed, 26 insertions(+), 38 deletions(-) diff --git a/.devcontainer/swift/devcontainer.json b/.devcontainer/swift/devcontainer.json index 97cd1bd022a2..5683bfb592e0 100644 --- a/.devcontainer/swift/devcontainer.json +++ b/.devcontainer/swift/devcontainer.json @@ -1,25 +1,28 @@ { - "extensions": [ - "github.vscode-codeql", - "hbenl.vscode-test-explorer", - "ms-vscode.test-adapter-converter", - "slevesque.vscode-zipexplorer", - "ms-vscode.cpptools" - ], - "settings": { - "files.watcherExclude": { - "**/target/**": true - }, - "codeQL.runningQueries.memory": 2048 - }, - "build": { - "dockerfile": "Dockerfile", - }, - "runArgs": [ - "--cap-add=SYS_PTRACE", - "--security-opt", - "seccomp=unconfined" - ], - "remoteUser": "vscode", - "onCreateCommand": ".devcontainer/swift/user.sh" + "extensions": [ + "github.vscode-codeql", + "hbenl.vscode-test-explorer", + "ms-vscode.test-adapter-converter", + "slevesque.vscode-zipexplorer", + "ms-vscode.cpptools" + ], + "features": { + "git-lfs": "latest" + }, + "settings": { + "files.watcherExclude": { + "**/target/**": true + }, + "codeQL.runningQueries.memory": 2048 + }, + "build": { + "dockerfile": "Dockerfile", + }, + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined" + ], + "remoteUser": "vscode", + "onCreateCommand": ".devcontainer/swift/user.sh" } diff --git a/.devcontainer/swift/root.sh b/.devcontainer/swift/root.sh index 33ffba0a741c..983435c209b4 100755 --- a/.devcontainer/swift/root.sh +++ b/.devcontainer/swift/root.sh @@ -3,9 +3,6 @@ set -xe BAZELISK_VERSION=v1.12.0 BAZELISK_DOWNLOAD_SHA=6b0bcb2ea15bca16fffabe6fda75803440375354c085480fe361d2cbf32501db -# install git lfs apt source -curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash - # install gh apt source (type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \ && sudo mkdir -p -m 755 /etc/apt/keyrings \ @@ -21,7 +18,6 @@ apt-get -y install --no-install-recommends \ python3-distutils \ python3-pip \ bash-completion \ - git-lfs \ gh # Install Bazel diff --git a/.devcontainer/swift/user.sh b/.devcontainer/swift/user.sh index 568fdecbfcfe..fbf8aca57a71 100755 --- a/.devcontainer/swift/user.sh +++ b/.devcontainer/swift/user.sh @@ -1,16 +1,5 @@ set -xe -# git lfs install may fail because codespaces can install its own hooks -# let's install it manually -for script in pre-push post-checkout post-commit post-merge; do - if [ -x .git/hooks/$script ]; then - sed -i "2i git lfs $script || exit 1" .git/hooks/$script - else - printf "#!/bin/bash\ngit lfs %s\n" $script > .git/hooks/$script - chmod +x .git/hooks/$script - fi -done - # add the workspace to the codeql search path mkdir -p /home/vscode/.config/codeql echo "--search-path /workspaces/codeql" > /home/vscode/.config/codeql/config