Skip to content

Commit b0d12eb

Browse files
authored
fix(shell-history): fix broken fish config script (#22)
* fix(shell-history): fix fish sytax and ensure creating the sym link * ci: test fish config * ci: ensure run tests on PRs * test(shell-history): use the latest fish feature * ci: use test.yaml from the latest feature-starter template * test: fix test for fish * test: fix test name * chore(shell-history): bump version * refactor(shell-history): use single quote * test(shell-history): more tests for fish * ci: remove failing test for now
1 parent 6c2f6a0 commit b0d12eb

5 files changed

Lines changed: 48 additions & 27 deletions

File tree

.github/workflows/test.yaml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,52 @@ on:
33
push:
44
branches:
55
- main
6+
pull_request:
67
workflow_dispatch:
78

89
jobs:
9-
test:
10+
test-autogenerated:
1011
runs-on: ubuntu-latest
11-
# continue-on-error: true
12+
continue-on-error: true
1213
strategy:
1314
matrix:
14-
include:
15-
- features: "dev-tunnel"
16-
baseImage: "mcr.microsoft.com/vscode/devcontainers/javascript-node:0-18"
17-
remoteUser: node
18-
- features: "dev-tunnel"
19-
baseImage: "mcr.microsoft.com/devcontainers/base:ubuntu"
20-
remoteUser: root
15+
features:
16+
- shell-history
17+
baseImage:
18+
- debian:latest
19+
- ubuntu:latest
20+
- mcr.microsoft.com/devcontainers/base:ubuntu
2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323

2424
- name: "Install latest devcontainer CLI"
2525
run: npm install -g @devcontainers/cli
2626

27-
- name: "Generating tests for '${{ matrix.feature }}' against '${{ matrix.baseImage }}'"
28-
run: devcontainer features test --features ${{ matrix.feature }} --base-image ${{ matrix.baseImage }} --remote-user ${{ matrix.remoteUser }} .
27+
- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
28+
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
2929

30+
test-scenarios:
31+
runs-on: ubuntu-latest
32+
continue-on-error: true
33+
strategy:
34+
matrix:
35+
features:
36+
- dev-tunnels
37+
- shell-history
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: "Install latest devcontainer CLI"
42+
run: npm install -g @devcontainers/cli
43+
44+
- name: "Generating tests for '${{ matrix.features }}' scenarios"
45+
run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated .
3046

3147
# test-global:
3248
# runs-on: ubuntu-latest
3349
# continue-on-error: true
3450
# steps:
35-
# - uses: actions/checkout@v2
51+
# - uses: actions/checkout@v4
3652

3753
# - name: "Install latest devcontainer CLI"
3854
# run: npm install -g @devcontainers/cli

src/shell-history/devcontainer-feature.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Shell History",
33
"id": "shell-history",
4-
"version": "0.0.5",
4+
"version": "0.0.6",
55
"description": "Preserve shell history across dev container instances. Currently supports bash, zsh, and fish",
66
"options": {},
77
"mounts": [
@@ -18,4 +18,4 @@
1818
"onCreateCommand": {
1919
"shell-history": "/usr/local/share/stuartleeks-devcontainer-features/shell-history/scripts/oncreate.sh"
2020
}
21-
}
21+
}

src/shell-history/oncreate.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,18 @@ EOF
4242

4343
# Create symlink for fish
4444
mkdir -p $HOME/.config/fish
45-
cat << EOF >> "$HOME/.config/fish/config.fish"
46-
if [ -z "\$XDG_DATA_HOME" ];
47-
then
45+
cat << 'EOF' >> "$HOME/.config/fish/config.fish"
46+
if [ -z "$XDG_DATA_HOME" ];
4847
set history_location ~/.local/share/fish/fish_history
4948
else
50-
set history_location \$XDG_DATA_HOME/fish/fish_history
51-
fi
49+
set history_location $XDG_DATA_HOME/fish/fish_history
50+
end
5251
53-
if [ -f \$history_location ]; then
54-
mv \$history_location "\$history_location-old"
55-
fi
52+
if [ -f $history_location ];
53+
mv $history_location "$history_location-old"
54+
end
5655
57-
ln -s /dc/shellhistory/fish_history \$history_location
56+
ln -fs /dc/shellhistory/fish_history $history_location
5857
EOF
5958

6059
fix_permissions /dc/shellhistory

test/shell-history/fish_shell.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22

33
set -e
44

5-
./_default.sh
5+
# Optional: Import test library bundled with the devcontainer CLI
6+
source dev-container-features-test-lib
7+
8+
# Feature-specific tests
9+
check "check fish config script validity" fish -c "source $HOME/.config/fish/config.fish"
10+
check "check fish config script content" bash -c "cat $HOME/.config/fish/config.fish | grep -q 'XDG_DATA_HOME'"
11+
check "cache dir permission" bash -c "test -w /dc/shellhistory"

test/shell-history/scenarios.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"fish_shell": {
1818
"image": "mcr.microsoft.com/devcontainers/base:debian",
1919
"features": {
20-
"ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {},
20+
"ghcr.io/meaningful-ooo/devcontainer-features/fish:latest": {},
2121
"shell-history": {}
2222
}
2323
},
@@ -28,4 +28,4 @@
2828
},
2929
"remoteUser": "root"
3030
}
31-
}
31+
}

0 commit comments

Comments
 (0)