Skip to content

Commit 71155b4

Browse files
authored
Merge pull request #1 from gilesknap/main
fix the devcontainer for local feature testing
2 parents 67a45f0 + 23a8ed8 commit 71155b4

File tree

15 files changed

+224
-175
lines changed

15 files changed

+224
-175
lines changed

.devcontainer/devcontainer.json

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
1+
// For format details, see https://containers.dev/implementors/json_reference/
12
{
2-
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bookworm",
3+
"name": "Python 3 Developer Container",
4+
"build": {
5+
"dockerfile": "../Dockerfile",
6+
"target": "developer"
7+
},
38
"customizations": {
49
"vscode": {
10+
// Set *default* container specific settings.json values on container create.
511
"settings": {
6-
"json.schemas": [
7-
{
8-
"fileMatch": [
9-
"*/devcontainer-feature.json"
10-
],
11-
"url": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainerFeature.schema.json"
12-
}
13-
]
12+
"python.defaultInterpreterPath": "/venv/bin/python"
1413
},
14+
// Add the IDs of extensions you want installed when the container is created.
1515
"extensions": [
16-
"mads-hartmann.bash-ide-vscode"
16+
"ms-python.python",
17+
"github.vscode-github-actions",
18+
"tamasfe.even-better-toml",
19+
"redhat.vscode-yaml",
20+
"ryanluker.vscode-coverage-gutters",
21+
"charliermarsh.ruff",
22+
"ms-azuretools.vscode-docker"
1723
]
1824
}
1925
},
2026
"features": {
21-
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
27+
"./features/terminalhistory": {}
2228
},
23-
"remoteUser": "node",
24-
"updateContentCommand": "npm install -g @devcontainers/cli"
25-
}
29+
"runArgs": [
30+
// Allow the container to access the host X11 display and EPICS CA
31+
"--net=host",
32+
// Make sure SELinux does not disable with access to host filesystems like tmp
33+
"--security-opt=label=disable"
34+
],
35+
// Mount the parent as /workspaces so we can pip install peers as editable
36+
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
37+
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/devcontainer_rc"
38+
}

src/color/devcontainer-feature.json renamed to .devcontainer/features/color/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"installsAfter": [
1919
"ghcr.io/devcontainers/features/common-utils"
2020
]
21-
}
21+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ cat > /usr/local/bin/color \
2323
echo "my favorite color is ${FAVORITE}"
2424
EOF
2525

26-
chmod +x /usr/local/bin/color
26+
chmod +x /usr/local/bin/color
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "BASH terminal auto history configuration",
3+
"id": "bashconfig",
4+
"version": "1.0.0",
5+
"description": "Make default BASH terminal nicer",
6+
"containerEnv": {
7+
"CONFIG_FOLDER": "/devcontainer_rc",
8+
"CONFIG_STAGING": "/devcontainer_staging"
9+
},
10+
"mounts": [
11+
{
12+
"source": "${localEnv:HOME}/.config/devcontainer_rc",
13+
"target": "/devcontainer_rc",
14+
"type": "bind"
15+
}
16+
],
17+
"onCreateCommand": "bash /devcontainer_staging/onCreateCommand.sh"
18+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
mkdir -p $CONFIG_STAGING
4+
5+
# -------------------------------------------------------------------------------
6+
cat > $CONFIG_STAGING/onCreateCommand.sh \
7+
<< EOF
8+
#!/bin/bash
9+
10+
# copy in the opinionated default settings from the feature
11+
cp $CONFIG_STAGING/feature_settings_rc $CONFIG_FOLDER/feature_settings_rc
12+
13+
# copy in the user editable settings unless they already exist
14+
if [[ ! -f $CONFIG_FOLDER/bashrc ]] ; then
15+
cp $CONFIG_STAGING/bashrc $CONFIG_FOLDER
16+
cp $CONFIG_STAGING/inputrc $CONFIG_FOLDER
17+
fi
18+
19+
# hook in the config to the root account
20+
ln -s $CONFIG_FOLDER/inputrc /root/.inputrc
21+
echo "source $CONFIG_FOLDER/bashrc" >> /root/.bashrc
22+
EOF
23+
24+
# -------------------------------------------------------------------------------
25+
cat > $CONFIG_STAGING/inputrc \
26+
<< EOF
27+
# Readline configuration for bash shell.
28+
29+
# Incremental history searching with up and down arrows (C-P and C-N for old
30+
# style navigation).
31+
"\e[A": history-search-backward
32+
"\e[B": history-search-forward
33+
34+
# Control left and right for word movement
35+
"\e[5C": forward-word
36+
"\e[5D": backward-word
37+
EOF
38+
39+
# -------------------------------------------------------------------------------
40+
cat > $CONFIG_STAGING/bashrc \
41+
<< EOF
42+
#!/bin/bash
43+
44+
# execute default opinionated settings - delete this line to remove defaults
45+
source $CONFIG_FOLDER/feature_settings_rc
46+
47+
# add your personal custom settings below
48+
EOF
49+
50+
# -------------------------------------------------------------------------------
51+
cat > $CONFIG_STAGING/feature_settings_rc \
52+
<< EOF
53+
#!/bin/bash
54+
55+
# default opinioned bash configuration
56+
57+
# set the prompt
58+
export PS1="\[\033[1;34m\]\W \[\033[0m\]# "
59+
60+
# enable enternal shared history
61+
export HISTCONTROL=ignoreboth:erasedups
62+
export HISTFILESIZE=-1
63+
export SAVEHIST=-1
64+
export HISTFILE=$CONFIG_FOLDER/.bash_eternal_history
65+
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
66+
EOF

.github/workflows/release.yaml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,25 @@ jobs:
2323
env:
2424
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2525

26-
- name: Create PR for Documentation
27-
id: push_image_info
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30-
run: |
31-
set -e
32-
echo "Start."
33-
# Configure git and Push updates
34-
git config --global user.email github-actions[bot]@users.noreply.github.com
35-
git config --global user.name github-actions[bot]
36-
git config pull.rebase false
37-
branch=automated-documentation-update-$GITHUB_RUN_ID
38-
git checkout -b $branch
39-
message='Automated documentation update'
40-
# Add / update and commit
41-
git add */**/README.md
42-
git commit -m 'Automated documentation update [skip ci]' || export NO_UPDATES=true
43-
# Push
44-
if [ "$NO_UPDATES" != "true" ] ; then
45-
git push origin "$branch"
46-
gh pr create --title "$message" --body "$message"
47-
fi
26+
# - name: Create PR for Documentation
27+
# id: push_image_info
28+
# env:
29+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
# run: |
31+
# set -e
32+
# echo "Start."
33+
# # Configure git and Push updates
34+
# git config --global user.email github-actions[bot]@users.noreply.github.com
35+
# git config --global user.name github-actions[bot]
36+
# git config pull.rebase false
37+
# branch=automated-documentation-update-$GITHUB_RUN_ID
38+
# git checkout -b $branch
39+
# message='Automated documentation update'
40+
# # Add / update and commit
41+
# git add */**/README.md
42+
# git commit -m 'Automated documentation update [skip ci]' || export NO_UPDATES=true
43+
# # Push
44+
# if [ "$NO_UPDATES" != "true" ] ; then
45+
# git push origin "$branch"
46+
# gh pr create --title "$message" --body "$message"
47+
# fi

.github/workflows/test.yaml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,46 @@ jobs:
1313
strategy:
1414
matrix:
1515
features:
16-
- color
17-
- hello
16+
- terminal-history
1817
baseImage:
1918
- debian:latest
2019
- ubuntu:latest
21-
- mcr.microsoft.com/devcontainers/base:ubuntu
2220
steps:
2321
- uses: actions/checkout@v4
2422

2523
- name: "Install latest devcontainer CLI"
26-
run: npm install -g @devcontainers/cli
27-
24+
run: |
25+
npm install -g @devcontainers/cli
26+
mkdir -p ~/.config/devcontainer_rc
27+
2828
- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
2929
run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .
3030

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 .
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 .

.github/workflows/validate.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: "Validate devcontainer-feature.json files"
22
on:
3-
workflow_dispatch:
43
pull_request:
54

65
jobs:

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The devcontainer should use the developer target and run as root with podman
2+
# or docker with user namespaces.
3+
ARG PYTHON_VERSION=3.11
4+
FROM python:${PYTHON_VERSION} AS developer
5+
6+
# Set up a virtual environment and put it in PATH
7+
RUN python -m venv /venv
8+
ENV PATH=/venv/bin:$PATH

src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.devcontainer/features

0 commit comments

Comments
 (0)