Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 8239951

Browse files
authored
Smoke test action UID/GID fix, use main for build util
1 parent f9e5fb7 commit 8239951

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

.github/actions/smoke-test/action.yaml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,28 @@ inputs:
1616
runs:
1717
using: composite
1818
steps:
19+
- name: Checkout main
20+
id: checkout_release
21+
uses: actions/checkout@v2
22+
with:
23+
path: '__build'
24+
ref: 'main'
25+
1926
- name: Build image
2027
id: build_image
2128
shell: bash
2229
run: |
2330
set -e
2431
25-
# Run test build
32+
# Symlink build scripts from main to improve security when testing PRs
33+
cd "$GITHUB_WORKSPACE/__build"
2634
yarn install
35+
rm -rf build node_modules
36+
ln -s "$GITHUB_WORKSPACE/__build/build" build
37+
ln -s "$GITHUB_WORKSPACE/__build/node_modules" node_modules
38+
cd "$GITHUB_WORKSPACE"
39+
40+
# Run test build
2741
GIT_BRANCH=$(echo "${{ github.ref }}" | grep -oP 'refs/(heads|tags)/\K(.+)')
2842
if [ "$GIT_BRANCH" == "" ]; then
2943
GIT_BRANCH=main
@@ -55,6 +69,16 @@ runs:
5569
container_name="vscdc-test-container"
5670
docker run -d --name ${container_name} --rm --init --privileged -v "$(pwd)/containers/${{ inputs.definition }}:/workspace" ${{ inputs.image }} /bin/sh -c 'while sleep 1000; do :; done'
5771
72+
# Update UID/GID for user in container - Actions uses different UID/GID than container
73+
# which causes bind mounts to be read only and cause certain write tests to fail
74+
# The dev container CLI handles this automatically but we're not using it.
75+
local_uid=$(id -u)
76+
local_gid=$(id -g)
77+
docker exec -u root ${container_name} /bin/sh -c "\
78+
echo \"(*) Update user UID/GID...\" \
79+
&& groupmod -g ${local_gid} ${{ inputs.user }} \
80+
&& usermod -u ${local_uid} -g ${local_gid} ${{ inputs.user }}"
81+
5882
# Fake out existence of extensions, VS Code Server
5983
echo "(*) Stubbing out extensions and VS Code Server..."
6084
dev_container_relative_path="containers/${{ inputs.definition }}/.devcontainer"
@@ -74,8 +98,6 @@ runs:
7498
echo "(*) Running test..."
7599
docker exec -u "${{ inputs.user }}" ${container_name} /bin/sh -c '\
76100
set -e \
77-
&& id \
78-
&& echo "$HOME" \
79101
&& cd /workspace \
80102
&& if [ -f "test-project/test.sh" ]; then \
81103
cd test-project \

0 commit comments

Comments
 (0)