Skip to content

Commit 0ed28a3

Browse files
authored
Merge pull request #1 from gilesknap/ci
Get CI working and publishing feature version based on git tag
2 parents 2c3b59a + 1f3a3e3 commit 0ed28a3

File tree

6 files changed

+52
-56
lines changed

6 files changed

+52
-56
lines changed

.devcontainer/features/bash-config/README.md

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,14 @@
22

33
## Defaults
44

5-
When this feature is first called, onCreateCommand.sh is created and called in `devcontainer-feature`.
6-
This creates and installs a default bash terminal configuration from `feature_settings_rc` which contains opinionated default BASH terminal settings such as:
7-
* A minimalist, blue bash prompt.
8-
* Eternal, shared history between containers using this feature.
9-
10-
## Customisation
11-
12-
The user can specify their own terminal preferences in `$CONFIG_STAGING/bashrc`, which defaults to `/devcontainer_staging/bashrc`.
13-
Then the container is rebuilt, if `bashrc` already exists it won't be overwritten, preserving changes. If the container has been built once already, the existing bashrc must be deleted in order for your changes to be applied.
5+
The default, opinionated configuration is defined in
6+
`$HOME/.config/bash-config/bash-config-rc` and includes the following:
147

8+
- Persistent history across all devcontainers that use this feature
9+
- The MS devcontainer bash prompt with git branch and status
10+
- history search with up/down arrows (.inputrc)
11+
- ctrl-left or right arrow for word navigation (.inputrc)
1512

13+
## Customisation
1614

17-
creates staging folder in container
18-
creates onCreateCommand.sh in the staging folder
19-
inputrc and bashrc are also created in the staging folder, containing incremental history searching and user customisations respectively
20-
feature_settings_rc is created in the staging fodler, which contains a PS1 setup and opinionated terminal features
21-
"onCreateCommand" is then exectuted inside the container during finalisation of container setup.
22-
- This copies the contents of feature_settings_rc into devcontainer_rc
23-
- then copies bashrc and inputrc into the container, unless they exist already to prevent overwriting user edits
24-
- then adds root permissions.
25-
A symbolic link to /root/ is created The items in the CONFIG_FOLDER
26-
our bashrc is called by /root/.bashrc
15+
Can be customized by editing `$HOME/.config/bash-config/bashrc`

.devcontainer/features/bash-config/devcontainer-feature.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "Lightweight and configurable BASH eternal history",
33
//ID *must* match parent folder name *exactly*
44
"id": "bash-config",
5-
"version": "1.0.0",
5+
// a default beta version that is replaced by CI when doing tagged releases
6+
"version": "0.0.1-b1",
67
"description": "Lightweight BASH setup with eternal history and PS1 tweaks. Fully configurable.",
78
"documentationURL": "https://raw.githubusercontent.com/DiamondRC/devcontainer-features/refs/heads/main/.devcontainer/features/bash-config/README.md",
89
"containerEnv": {
@@ -17,4 +18,4 @@
1718
}
1819
],
1920
"onCreateCommand": "bash /devcontainer_staging/onCreateCommand.sh"
20-
}
21+
}

.github/workflows/release.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
name: "Release dev container features & Generate Documentation"
22
on:
33
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
47

58
jobs:
69
deploy:
7-
if: ${{ github.ref == 'refs/heads/main' }}
810
runs-on: ubuntu-latest
911
permissions:
1012
contents: write
@@ -13,13 +15,23 @@ jobs:
1315
steps:
1416
- uses: actions/checkout@v4
1517

18+
- name: patch in version tag
19+
# patch the version tag if the version is a valid semver. If not the
20+
# default to the
21+
run: |
22+
if [[ ${{ github.ref_name }} =~ ^[0-9]+\.[0-9]+.+ ]] ; then
23+
sed -i s/0\.0\.0-b1/${{ github.ref_name }}/ $(find .devcontainer -name devcontainer-feature.json)
24+
# dump the modified json for debugging
25+
cat $(find .devcontainer -name devcontainer-feature.json)
26+
fi
27+
1628
- name: "Publish Features"
1729
uses: devcontainers/action@v1
1830
with:
1931
publish-features: "true"
2032
base-path-to-features: "./src"
2133
generate-docs: "true"
22-
34+
2335
env:
2436
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2537

.github/workflows/test.yaml

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
name: "CI - Test Features"
22
on:
33
push:
4-
branches:
5-
- main
64
pull_request:
7-
workflow_dispatch:
85

96
jobs:
107
test-autogenerated:
@@ -13,7 +10,7 @@ jobs:
1310
strategy:
1411
matrix:
1512
features:
16-
- terminal-history
13+
- bash-config
1714
baseImage:
1815
- debian:latest
1916
- ubuntu:latest
@@ -24,35 +21,7 @@ jobs:
2421
run: |
2522
npm install -g @devcontainers/cli
2623
mkdir -p ~/.config/devcontainer_rc
27-
24+
2825
- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
2926
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
3027

31-
# test-scenarios:
32-
# runs-on: ubuntu-latest
33-
# continue-on-error: true
34-
# strategy:
35-
# matrix:
36-
# features:
37-
# - color
38-
# - hello
39-
# steps:
40-
# - uses: actions/checkout@v4
41-
#
42-
# - name: "Install latest devcontainer CLI"
43-
# run: npm install -g @devcontainers/cli
44-
#
45-
# - name: "Generating tests for '${{ matrix.features }}' scenarios"
46-
# run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated .
47-
#
48-
# test-global:
49-
# runs-on: ubuntu-latest
50-
# continue-on-error: true
51-
# steps:
52-
# - uses: actions/checkout@v4
53-
#
54-
# - name: "Install latest devcontainer CLI"
55-
# run: npm install -g @devcontainers/cli
56-
#
57-
# - name: "Testing global scenarios"
58-
# run: devcontainer features test --global-scenarios-only .

test/bash-config/scenarios.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"hello": {
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4+
"features": {
5+
"bash-config": {}
6+
}
7+
}
8+
}

test/bash-config/test.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Import test library bundled with the devcontainer CLI
6+
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
7+
# Provides the 'check' and 'reportResults' commands.
8+
source dev-container-features-test-lib
9+
10+
# Feature-specific tests
11+
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
12+
# check <LABEL> <cmd> [args...]
13+
check "execute command" bash -c "test $HISTFILE == $CONFIG_FOLDER/.bash_eternal_history"
14+
15+
# Report results
16+
# If any of the checks above exited with a non-zero exit code, the test will fail.
17+
reportResults

0 commit comments

Comments
 (0)