Skip to content

Commit db61bb9

Browse files
committed
Fix merge conflicts: consistent CI-time sync approach
- Resolve 5 merge conflicts favoring CI-time generation approach - Fix .gitignore to match actual paths (src/*/common-setup.sh, not _lib/) - Untrack per-feature common-setup.sh copies (now gitignored, generated by CI) - Update docs to reference correct test path (test/_global/)
1 parent 61bed5f commit db61bb9

28 files changed

+72
-1463
lines changed

.github/workflows/docker-in-docker-stress-test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v6
1717

18+
- name: "Sync shared scripts into features"
19+
run: bash scripts/sync-common-setup.sh
20+
1821
- name: "Install latest devcontainer CLI"
1922
run: npm install -g @devcontainers/cli
2023

@@ -30,6 +33,9 @@ jobs:
3033
steps:
3134
- uses: actions/checkout@v6
3235

36+
- name: "Sync shared scripts into features"
37+
run: bash scripts/sync-common-setup.sh
38+
3339
- name: "Install latest devcontainer CLI"
3440
run: npm install -g @devcontainers/cli
3541

.github/workflows/release.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v6
1717

18+
- name: "Sync shared scripts into features"
19+
run: bash scripts/sync-common-setup.sh
20+
1821
- name: "Publish"
1922
uses: devcontainers/action@v1
2023
with:

.github/workflows/test-all.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ jobs:
5454
steps:
5555
- uses: actions/checkout@v6
5656

57+
- name: "Sync shared scripts into features"
58+
run: bash scripts/sync-common-setup.sh
59+
5760
- name: "Install latest devcontainer CLI"
5861
run: npm install -g @devcontainers/cli
5962

6063
- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
61-
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
64+
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
6265

6366
test-scenarios:
6467
runs-on: ubuntu-latest
@@ -98,6 +101,9 @@ jobs:
98101
steps:
99102
- uses: actions/checkout@v6
100103

104+
- name: "Sync shared scripts into features"
105+
run: bash scripts/sync-common-setup.sh
106+
101107
- name: "Install latest devcontainer CLI"
102108
run: npm install -g @devcontainers/cli
103109

@@ -110,6 +116,9 @@ jobs:
110116
steps:
111117
- uses: actions/checkout@v6
112118

119+
- name: "Sync shared scripts into features"
120+
run: bash scripts/sync-common-setup.sh
121+
113122
- name: "Install latest devcontainer CLI"
114123
run: npm install -g @devcontainers/cli
115124

.github/workflows/test-manual.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v6
2323

24+
- name: "Sync shared scripts into features"
25+
run: bash scripts/sync-common-setup.sh
26+
2427
- name: "Install latest devcontainer CLI"
2528
run: npm install -g @devcontainers/cli
2629

.github/workflows/test-pr-arm64.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ jobs:
4444
steps:
4545
- uses: actions/checkout@v6
4646

47+
- name: "Sync shared scripts into features"
48+
run: bash scripts/sync-common-setup.sh
49+
4750
- name: "Install latest devcontainer CLI"
4851
run: npm install -g @devcontainers/cli
4952

@@ -60,6 +63,9 @@ jobs:
6063
steps:
6164
- uses: actions/checkout@v6
6265

66+
- name: "Sync shared scripts into features"
67+
run: bash scripts/sync-common-setup.sh
68+
6369
- name: "Install latest devcontainer CLI"
6470
run: npm install -g @devcontainers/cli
6571

.github/workflows/test-pr.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ jobs:
7070
steps:
7171
- uses: actions/checkout@v6
7272

73+
- name: "Sync shared scripts into features"
74+
run: bash scripts/sync-common-setup.sh
75+
7376
- name: "Install latest devcontainer CLI"
7477
run: npm install -g @devcontainers/cli
7578

@@ -86,6 +89,9 @@ jobs:
8689
steps:
8790
- uses: actions/checkout@v6
8891

92+
- name: "Sync shared scripts into features"
93+
run: bash scripts/sync-common-setup.sh
94+
8995
- name: "Install latest devcontainer CLI"
9096
run: npm install -g @devcontainers/cli
9197

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
workspace.code-workspace
1+
workspace.code-workspace
2+
3+
# Auto-generated by scripts/sync-common-setup.sh at CI/build time
4+
src/*/common-setup.sh

.rebase-continue.sh

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

SHARED_CODE.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ Multiple features need the same helper functions (e.g., user selection logic). T
88

99
## Solution
1010

11-
We maintain a **single source of truth** with a **sync mechanism** to deploy to each feature:
11+
We maintain a **single source of truth** with a **CI-time sync mechanism** to deploy to each feature:
1212

1313
### Single Source
1414
- **Location**: `scripts/lib/common-setup.sh`
1515
- **Contains**: Shared helper functions (currently user selection logic)
1616
- **Maintenance**: All updates happen here
1717

1818
### Deployment
19-
- **Mechanism**: `scripts/sync-common-setup.sh`
20-
- **Target**: Copies to each feature's directory as `common-setup.sh`
19+
- **Mechanism**: `scripts/sync-common-setup.sh` (runs automatically in CI)
20+
- **Target**: Copies to each feature's directory as `common-setup.sh` at build/test time
2121
- **Reason**: Devcontainer packaging requires files to be within each feature's directory
22+
- **Note**: The copies are `.gitignore`d — only the source file is tracked in git
2223

2324
## Workflow
2425

2526
### Making Changes
2627

2728
1. **Edit the source**: Modify `scripts/lib/common-setup.sh`
2829
2. **Test**: Run `bash test/_global/test-common-setup.sh`
29-
3. **Sync**: Run `./scripts/sync-common-setup.sh`
30-
4. **Commit**: Include both source and deployed copies
30+
3. **Commit**: Only the source file needs to be committed
3131

3232
```bash
3333
# Edit the source
@@ -36,25 +36,25 @@ vim scripts/lib/common-setup.sh
3636
# Test
3737
bash test/_global/test-common-setup.sh
3838

39-
# Deploy to all features
40-
./scripts/sync-common-setup.sh
41-
42-
# Commit everything
43-
git add scripts/lib/common-setup.sh src/*/common-setup.sh
39+
# Commit just the source
40+
git add scripts/lib/common-setup.sh
4441
git commit -m "Update common-setup.sh helper function"
4542
```
4643

47-
### Verification
44+
### Local Development
4845

49-
The sync script is idempotent - running it multiple times with the same source produces the same result. After syncing, you can verify:
46+
To generate the copies locally (e.g., for testing features outside CI):
5047

5148
```bash
52-
# Check that all copies are identical
53-
for f in src/*/common-setup.sh; do
54-
diff -q scripts/lib/common-setup.sh "$f" || echo "MISMATCH: $f"
55-
done
49+
./scripts/sync-common-setup.sh
5650
```
5751

52+
### CI Integration
53+
54+
All CI workflows (test, release, stress test) automatically run `sync-common-setup.sh`
55+
after checkout and before the devcontainer CLI packages features. This ensures the
56+
copies are always present and up-to-date without tracking them in git.
57+
5858
## Why Not Use Shared Files?
5959

6060
The devcontainer CLI packages each feature independently. When a feature is installed:
@@ -81,10 +81,10 @@ 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**: 16 features, each with `src/FEATURE/common-setup.sh`
85-
- **Sync Script**: `scripts/sync-common-setup.sh`
84+
- **Deployed**: 16 features, each with `src/FEATURE/common-setup.sh` (generated at CI time, gitignored)
85+
- **Sync Script**: `scripts/sync-common-setup.sh` (called by all CI workflows)
8686
- **Tests**: `test/_global/test-common-setup.sh` (14 test cases)
87-
- **Benefits**: Eliminated ~188 lines of inline duplicated logic from install scripts
87+
- **Benefits**: Eliminated ~188 lines of inline duplicated logic from install scripts, zero duplicate files tracked in git
8888

8989
## References
9090

scripts/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,15 @@ 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 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 present in each feature's directory at packaging time. This is handled automatically by CI — all workflows run `scripts/sync-common-setup.sh` after checkout and before packaging.
2323

24-
```bash
25-
./scripts/sync-common-setup.sh
26-
```
27-
28-
This copies `scripts/lib/common-setup.sh` to all features:
29-
- `src/anaconda/common-setup.sh`
30-
- `src/docker-in-docker/common-setup.sh`
31-
- etc.
24+
The copies are `.gitignore`d — only the source file is tracked in git.
3225

3326
### Workflow
3427

3528
1. **Edit**: Make changes to `scripts/lib/common-setup.sh`
3629
2. **Test**: Run `bash test/_global/test-common-setup.sh` to verify
37-
3. **Sync**: Run `./scripts/sync-common-setup.sh` to deploy to all features
38-
4. **Commit**: Commit both the source and all copies together
30+
3. **Commit**: Only the source file needs to be committed
3931

4032
### Why Copies?
4133

@@ -48,12 +40,20 @@ Therefore, each feature needs its own copy of the helper to ensure it's availabl
4840

4941
## Testing
5042

51-
Tests are located in `test/_global/` and reference the source of truth directly:
43+
Tests are located in `test/_global/` and source from the canonical `scripts/lib/common-setup.sh`:
5244

5345
```bash
5446
bash test/_global/test-common-setup.sh
5547
```
5648

49+
### Local Development
50+
51+
To generate the copies locally (e.g., for testing features outside CI):
52+
53+
```bash
54+
./scripts/sync-common-setup.sh
55+
```
56+
5757
## Future
5858

5959
This approach is a workaround for the current limitation. The devcontainer spec has a proposal for an `include` property in `devcontainer-feature.json` that would allow native code sharing (see [devcontainers/spec#129](https://github.com/devcontainers/spec/issues/129)). Once implemented, this sync mechanism can be removed.

0 commit comments

Comments
 (0)