Skip to content

Commit 61bed5f

Browse files
committed
Move common-setup.sh from _lib/ to feature root, fix test runner
1 parent 27284f4 commit 61bed5f

File tree

37 files changed

+36
-1488
lines changed

37 files changed

+36
-1488
lines changed

SHARED_CODE.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ We maintain a **single source of truth** with a **sync mechanism** to deploy to
1717

1818
### Deployment
1919
- **Mechanism**: `scripts/sync-common-setup.sh`
20-
- **Target**: Copies to each feature's `_lib/` directory
20+
- **Target**: Copies to each feature's directory as `common-setup.sh`
2121
- **Reason**: Devcontainer packaging requires files to be within each feature's directory
2222

2323
## Workflow
2424

2525
### Making Changes
2626

2727
1. **Edit the source**: Modify `scripts/lib/common-setup.sh`
28-
2. **Test**: Run `bash test/_lib/test-common-setup.sh`
28+
2. **Test**: Run `bash test/_global/test-common-setup.sh`
2929
3. **Sync**: Run `./scripts/sync-common-setup.sh`
3030
4. **Commit**: Include both source and deployed copies
3131

@@ -34,13 +34,13 @@ We maintain a **single source of truth** with a **sync mechanism** to deploy to
3434
vim scripts/lib/common-setup.sh
3535

3636
# Test
37-
bash test/_lib/test-common-setup.sh
37+
bash test/_global/test-common-setup.sh
3838

3939
# Deploy to all features
4040
./scripts/sync-common-setup.sh
4141

4242
# Commit everything
43-
git add scripts/lib/common-setup.sh src/*/_lib/common-setup.sh
43+
git add scripts/lib/common-setup.sh src/*/common-setup.sh
4444
git commit -m "Update common-setup.sh helper function"
4545
```
4646

@@ -50,7 +50,7 @@ The sync script is idempotent - running it multiple times with the same source p
5050

5151
```bash
5252
# Check that all copies are identical
53-
for f in src/*/_lib/common-setup.sh; do
53+
for f in src/*/common-setup.sh; do
5454
diff -q scripts/lib/common-setup.sh "$f" || echo "MISMATCH: $f"
5555
done
5656
```
@@ -81,14 +81,14 @@ The devcontainer spec has a proposal for an `include` property in `devcontainer-
8181

8282
As of this PR:
8383
- **Source**: `scripts/lib/common-setup.sh` (87 lines)
84-
- **Deployed**: 17 features, each with `src/FEATURE/_lib/common-setup.sh`
84+
- **Deployed**: 16 features, each with `src/FEATURE/common-setup.sh`
8585
- **Sync Script**: `scripts/sync-common-setup.sh`
86-
- **Tests**: `test/_lib/test-common-setup.sh` (14 test cases)
86+
- **Tests**: `test/_global/test-common-setup.sh` (14 test cases)
8787
- **Benefits**: Eliminated ~188 lines of inline duplicated logic from install scripts
8888

8989
## References
9090

9191
- [Devcontainer Spec Issue #129 - Share code between features](https://github.com/devcontainers/spec/issues/129)
9292
- [Features Library Proposal](https://github.com/devcontainers/spec/blob/main/proposals/features-library.md)
93-
- Test documentation: `test/_lib/README.md`
93+
- Test documentation: `test/_global/test-common-setup.sh`
9494
- Sync script documentation: `scripts/README.md`

scripts/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ scripts/
1919

2020
### Deploying Changes
2121

22-
Due to the devcontainer CLI's packaging behavior (each feature is packaged independently), the helper must be deployed to each feature's `_lib/` directory. We maintain this through a sync script:
22+
Due to the devcontainer CLI's packaging behavior (each feature is packaged independently), the helper must be deployed to each feature's directory. We maintain this through a sync script:
2323

2424
```bash
2525
./scripts/sync-common-setup.sh
2626
```
2727

2828
This copies `scripts/lib/common-setup.sh` to all features:
29-
- `src/anaconda/_lib/common-setup.sh`
30-
- `src/docker-in-docker/_lib/common-setup.sh`
29+
- `src/anaconda/common-setup.sh`
30+
- `src/docker-in-docker/common-setup.sh`
3131
- etc.
3232

3333
### Workflow
3434

3535
1. **Edit**: Make changes to `scripts/lib/common-setup.sh`
36-
2. **Test**: Run `bash test/_lib/test-common-setup.sh` to verify
36+
2. **Test**: Run `bash test/_global/test-common-setup.sh` to verify
3737
3. **Sync**: Run `./scripts/sync-common-setup.sh` to deploy to all features
3838
4. **Commit**: Commit both the source and all copies together
3939

@@ -48,10 +48,10 @@ Therefore, each feature needs its own copy of the helper to ensure it's availabl
4848

4949
## Testing
5050

51-
Tests are located in `test/_lib/` and reference the anaconda feature's copy as the source:
51+
Tests are located in `test/_global/` and reference the source of truth directly:
5252

5353
```bash
54-
bash test/_lib/test-common-setup.sh
54+
bash test/_global/test-common-setup.sh
5555
```
5656

5757
## Future

scripts/sync-common-setup.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Licensed under the MIT License. See https://github.com/devcontainers/features/blob/main/LICENSE for license information.
55
#-------------------------------------------------------------------------------------------------------------------------
66
#
7-
# Script to sync common-setup.sh from the source to all feature _lib directories
7+
# Script to sync common-setup.sh from the source to all feature directories
88
# This maintains a single source of truth while deploying to each feature for packaging
99
#
1010
# Usage: ./scripts/sync-common-setup.sh
@@ -51,16 +51,12 @@ fi
5151
UPDATED_COUNT=0
5252

5353
for feature in "${FEATURES[@]}"; do
54-
TARGET_DIR="${REPO_ROOT}/src/${feature}/_lib"
55-
TARGET_FILE="${TARGET_DIR}/common-setup.sh"
56-
57-
# Create _lib directory if it doesn't exist
58-
mkdir -p "${TARGET_DIR}"
54+
TARGET_FILE="${REPO_ROOT}/src/${feature}/common-setup.sh"
5955

6056
# Copy the file
6157
cp "${SOURCE_FILE}" "${TARGET_FILE}"
6258

63-
echo "✓ Synced to src/${feature}/_lib/common-setup.sh"
59+
echo "✓ Synced to src/${feature}/common-setup.sh"
6460
UPDATED_COUNT=$((UPDATED_COUNT + 1))
6561
done
6662

@@ -71,5 +67,5 @@ echo "Updated ${UPDATED_COUNT} features"
7167
echo "======================================"
7268
echo ""
7369
echo "Note: After running this script, commit the changes:"
74-
echo " git add src/*/lib/common-setup.sh"
70+
echo " git add src/*/common-setup.sh"
7571
echo " git commit -m 'Sync common-setup.sh to all features'"

src/anaconda/_lib/common-setup.sh

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

src/anaconda/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ chmod +x /etc/profile.d/00-restore-env.sh
8383

8484
# Source common helper functions
8585
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
86-
source "${SCRIPT_DIR}/_lib/common-setup.sh"
86+
source "${SCRIPT_DIR}/common-setup.sh"
8787

8888
# Determine the appropriate non-root user
8989
USERNAME=$(determine_user_from_input "${USERNAME}" "root")

src/conda/_lib/common-setup.sh

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

src/conda/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ chmod +x /etc/profile.d/00-restore-env.sh
2929

3030
# Source common helper functions
3131
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
32-
source "${SCRIPT_DIR}/_lib/common-setup.sh"
32+
source "${SCRIPT_DIR}/common-setup.sh"
3333

3434
# Determine the appropriate non-root user
3535
USERNAME=$(determine_user_from_input "${USERNAME}" "root")

0 commit comments

Comments
 (0)