-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #831 from swyddfa/develop
New Release
- Loading branch information
Showing
89 changed files
with
3,492 additions
and
1,036 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM mcr.microsoft.com/devcontainers/base:jammy | ||
|
||
COPY tools.mk / | ||
|
||
RUN apt-get update \ | ||
&& export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get -y install --no-install-recommends python3-venv \ | ||
&& su vscode -c "make -f tools.mk tools" \ | ||
&& rm tools.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu | ||
{ | ||
"name": "Ubuntu", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "ghcr.io/swyddfa/esbonio-devenv:latest", | ||
// "build": { | ||
// "dockerfile": "Dockerfile" | ||
// }, | ||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "uname -a", | ||
// Configure tool-specific properties. | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"charliermarsh.ruff", | ||
"ms-python.python", | ||
"tamasfe.even-better-toml" | ||
] | ||
} | ||
} | ||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
ARCH ?= $(shell arch) | ||
BIN ?= $(HOME)/.local/bin | ||
|
||
ifeq ($(strip $(ARCH)),) | ||
$(error Unable to determine platform architecture) | ||
endif | ||
|
||
HATCH_VERSION = 1.10.0 | ||
NODE_VERSION := 18.20.2 | ||
|
||
# The versions of Python we support | ||
PYXX_versions := 3.8 3.9 3.10 3.11 3.12 | ||
PY_INTERPRETERS = | ||
|
||
# Hatch is not only used for building packages, but bootstrapping any missing | ||
# interpreters | ||
HATCH ?= $(or $(shell command -v hatch), $(BIN)/hatch) | ||
|
||
$(HATCH): | ||
curl -L --output /tmp/hatch.tar.gz https://github.com/pypa/hatch/releases/download/hatch-v$(HATCH_VERSION)/hatch-$(HATCH_VERSION)-$(ARCH)-unknown-linux-gnu.tar.gz | ||
tar -xf /tmp/hatch.tar.gz -C /tmp | ||
rm /tmp/hatch.tar.gz | ||
|
||
test -d $(BIN) || mkdir -p $(BIN) | ||
mv /tmp/hatch-$(HATCH_VERSION)-$(ARCH)-unknown-linux-gnu $(HATCH) | ||
|
||
$@ --version | ||
touch $@ | ||
|
||
# This effectively defines a function `PYXX` that takes a Python version number | ||
# (e.g. 3.8) and expands it out into a common block of code that will ensure a | ||
# verison of that interpreter is available to be used. | ||
# | ||
# The is perhaps a bit more complicated than I'd like, but it should mean that | ||
# the project's makefiles are useful both inside and outside of a devcontainer. | ||
# | ||
# `PYXX` has the following behavior: | ||
# - If possible, it will reuse the user's existing version of Python | ||
# i.e. $(shell command -v pythonX.X) | ||
# | ||
# - The user may force a specific interpreter to be used by setting the | ||
# variable when running make e.g. PYXX=/path/to/pythonX.X make ... | ||
# | ||
# - Otherwise, `make` will use `$(HATCH)` to install the given version of | ||
# Python under `$(BIN)` | ||
# | ||
# See: https://www.gnu.org/software/make/manual/html_node/Eval-Function.html | ||
define PYXX = | ||
|
||
PY$(subst .,,$1) ?= $$(shell command -v python$1) | ||
|
||
ifeq ($$(strip $$(PY$(subst .,,$1))),) | ||
|
||
PY$(subst .,,$1) := $$(BIN)/python$1 | ||
|
||
$$(PY$(subst .,,$1)): $$(HATCH) | ||
$$(HATCH) python find $1 || $$(HATCH) python install $1 | ||
ln -s $$$$($$(HATCH) python find $1) $$@ | ||
|
||
$$@ --version | ||
touch $$@ | ||
|
||
endif | ||
|
||
PY_INTERPRETERS += $$(PY$(subst .,,$1)) | ||
endef | ||
|
||
# Uncomment the following line to see what this expands into. | ||
#$(foreach version,$(PYXX_versions),$(info $(call PYXX,$(version)))) | ||
$(foreach version,$(PYXX_versions),$(eval $(call PYXX,$(version)))) | ||
|
||
# Set a default `python` command if there is not one already | ||
PY ?= $(shell command -v python3) | ||
|
||
ifeq ($(strip $(PY)),) | ||
PY := $(BIN)/python | ||
|
||
$(PY): $(PY312) | ||
ln -s $< $@ | ||
$@ --version | ||
touch $@ | ||
endif | ||
|
||
PY_INTERPRETERS += $(PY) | ||
#$(info $(PY_INTERPRETERS)) | ||
|
||
PIPX ?= $(shell command -v pipx) | ||
|
||
ifeq ($(strip $(PIPX)),) | ||
PIPX := $(BIN)/pipx | ||
PIPX_VERSION := 1.5.0 | ||
|
||
$(PIPX): | ||
curl -L -o $(BIN)/pipx.pyz https://github.com/pypa/pipx/releases/download/$(PIPX_VERSION)/pipx.pyz | ||
echo '#!/bin/bash\nexec $(PY) $(BIN)/pipx.pyz "$$@"' > $(PIPX) | ||
|
||
chmod +x $(PIPX) | ||
$@ --version | ||
touch $@ | ||
endif | ||
|
||
PRE_COMMIT ?= $(shell command -v pre-commit) | ||
|
||
ifeq ($(strip $(PRE_COMMIT)),) | ||
PRE_COMMIT := $(BIN)/pre-commit | ||
|
||
$(PRE_COMMIT): $(PIPX) | ||
$(PIPX) install pre-commit | ||
$@ --version | ||
touch $@ | ||
endif | ||
|
||
PY_TOOLS := $(HATCH) $(PIPX) $(PRE_COMMIT) | ||
|
||
# Node JS | ||
NPM ?= $(shell command -v npm) | ||
|
||
ifeq ($(strip $(NPM)),) | ||
|
||
NPM := $(BIN)/npm | ||
NODE := $(BIN)/node | ||
NODE_DIR := $(HOME)/.local/node | ||
|
||
$(NPM): | ||
curl -L --output /tmp/node.tar.xz https://nodejs.org/dist/v$(NODE_VERSION)/node-v$(NODE_VERSION)-linux-x64.tar.xz | ||
tar -xJf /tmp/node.tar.xz -C /tmp | ||
rm /tmp/node.tar.xz | ||
|
||
[ -d $(NODE_DIR) ] || mkdir -p $(NODE_DIR) | ||
mv /tmp/node-v$(NODE_VERSION)-linux-x64/* $(NODE_DIR) | ||
|
||
[ -d $(BIN) ] || mkdir -p $(BIN) | ||
ln -s $(NODE_DIR)/bin/node $(NODE) | ||
ln -s $(NODE_DIR)/bin/npm $(NPM) | ||
|
||
$(NODE) --version | ||
PATH=$(BIN) $(NPM) --version | ||
|
||
endif | ||
|
||
# One command to bootstrap all tools and check their versions | ||
tools: $(PY_INTERPRETERS) $(PY_TOOLS) $(NPM) | ||
for prog in $^ ; do echo -n "$${prog}\t" ; PATH=$(BIN) $${prog} --version; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: 'Build devcontainer' | ||
on: | ||
|
||
workflow_dispatch: | ||
|
||
pull_request: | ||
branches: | ||
- develop | ||
paths: | ||
- '.devcontainer/**' | ||
|
||
push: | ||
branches: | ||
- develop | ||
paths: | ||
- '.devcontainer/**' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }}-devenv | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to the Container registry | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
id: push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: .devcontainer/ | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"charliermarsh.ruff", | ||
"ms-python.python", | ||
"ms-python.black-formatter", | ||
"ms-python.isort", | ||
"swyddfa.esbonio" | ||
"tamasfe.even-better-toml" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.