diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 152b5cf..789c895 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -3,36 +3,52 @@ on: push: branches: - main + pull_request: workflow_dispatch: jobs: - test: + test-autogenerated: runs-on: ubuntu-latest - # continue-on-error: true + continue-on-error: true strategy: matrix: - include: - - features: "dev-tunnel" - baseImage: "mcr.microsoft.com/vscode/devcontainers/javascript-node:0-18" - remoteUser: node - - features: "dev-tunnel" - baseImage: "mcr.microsoft.com/devcontainers/base:ubuntu" - remoteUser: root + features: + - shell-history + baseImage: + - debian:latest + - ubuntu:latest + - mcr.microsoft.com/devcontainers/base:ubuntu steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Install latest devcontainer CLI" run: npm install -g @devcontainers/cli - - name: "Generating tests for '${{ matrix.feature }}' against '${{ matrix.baseImage }}'" - run: devcontainer features test --features ${{ matrix.feature }} --base-image ${{ matrix.baseImage }} --remote-user ${{ matrix.remoteUser }} . + - name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'" + run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} . + test-scenarios: + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + features: + - dev-tunnels + - shell-history + steps: + - uses: actions/checkout@v4 + + - name: "Install latest devcontainer CLI" + run: npm install -g @devcontainers/cli + + - name: "Generating tests for '${{ matrix.features }}' scenarios" + run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated . # test-global: # runs-on: ubuntu-latest # continue-on-error: true # steps: - # - uses: actions/checkout@v2 + # - uses: actions/checkout@v4 # - name: "Install latest devcontainer CLI" # run: npm install -g @devcontainers/cli diff --git a/src/shell-history/devcontainer-feature.json b/src/shell-history/devcontainer-feature.json index bbb9661..a03604f 100644 --- a/src/shell-history/devcontainer-feature.json +++ b/src/shell-history/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Shell History", "id": "shell-history", - "version": "0.0.5", + "version": "0.0.6", "description": "Preserve shell history across dev container instances. Currently supports bash, zsh, and fish", "options": {}, "mounts": [ @@ -18,4 +18,4 @@ "onCreateCommand": { "shell-history": "/usr/local/share/stuartleeks-devcontainer-features/shell-history/scripts/oncreate.sh" } -} \ No newline at end of file +} diff --git a/src/shell-history/oncreate.sh b/src/shell-history/oncreate.sh index 9284d60..7f1515c 100644 --- a/src/shell-history/oncreate.sh +++ b/src/shell-history/oncreate.sh @@ -42,19 +42,18 @@ EOF # Create symlink for fish mkdir -p $HOME/.config/fish -cat << EOF >> "$HOME/.config/fish/config.fish" -if [ -z "\$XDG_DATA_HOME" ]; -then +cat << 'EOF' >> "$HOME/.config/fish/config.fish" +if [ -z "$XDG_DATA_HOME" ]; set history_location ~/.local/share/fish/fish_history else - set history_location \$XDG_DATA_HOME/fish/fish_history -fi + set history_location $XDG_DATA_HOME/fish/fish_history +end -if [ -f \$history_location ]; then - mv \$history_location "\$history_location-old" -fi +if [ -f $history_location ]; + mv $history_location "$history_location-old" +end -ln -s /dc/shellhistory/fish_history \$history_location +ln -fs /dc/shellhistory/fish_history $history_location EOF fix_permissions /dc/shellhistory diff --git a/test/shell-history/fish_shell.sh b/test/shell-history/fish_shell.sh index c8a4294..b6457da 100644 --- a/test/shell-history/fish_shell.sh +++ b/test/shell-history/fish_shell.sh @@ -2,4 +2,10 @@ set -e -./_default.sh +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +# Feature-specific tests +check "check fish config script validity" fish -c "source $HOME/.config/fish/config.fish" +check "check fish config script content" bash -c "cat $HOME/.config/fish/config.fish | grep -q 'XDG_DATA_HOME'" +check "cache dir permission" bash -c "test -w /dc/shellhistory" diff --git a/test/shell-history/scenarios.json b/test/shell-history/scenarios.json index e2893ff..c7da136 100644 --- a/test/shell-history/scenarios.json +++ b/test/shell-history/scenarios.json @@ -17,7 +17,7 @@ "fish_shell": { "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { - "ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {}, + "ghcr.io/meaningful-ooo/devcontainer-features/fish:latest": {}, "shell-history": {} } }, @@ -28,4 +28,4 @@ }, "remoteUser": "root" } -} \ No newline at end of file +}