branch: elpa/flymake-collection commit 5318e0f6b2eae19977cbd8a9442011c5ddb3ff87 Author: Mohsin Kaleem <mohk...@kisara.moe> Commit: Mohsin Kaleem <mohk...@kisara.moe>
repo: Support dev-container workflow --- .devcontainer/devcontainer.json | 13 +++++++++++++ .github/workflows/test.yml | 2 +- Makefile | 23 +++++++++++++++++------ tests/checkers/Dockerfile | 28 ++++++++++++++++++---------- tests/checkers/run-test-case | 6 +++--- 5 files changed, 52 insertions(+), 20 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..be7eecbafb --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,13 @@ +{ + "name": "Flymake collection", + "build": { + "dockerfile": "../tests/checkers/Dockerfile" + }, + "remoteUser": "devcontainer", + "updateRemoteUserUID": true, + "customizations": { + "emacs": { + "inline-dir-locals": "((nil . ((eval . (add-to-list 'tramp-remote-path 'tramp-own-remote-path)))))" + } + } +} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16062a5e95..2f5a016ba9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,4 +19,4 @@ jobs: steps: - uses: actions/checkout@v2 - name: Run test suite - run: make test EMACS_BRANCH="${{ matrix.emacs_branch }}" + run: make docker EMACS_BRANCH="${{ matrix.emacs_branch }}" DOCKER_FLAGS='' DOCKER_COMMAND='make test' diff --git a/Makefile b/Makefile index b3cf917aac..8b9bc35bef 100644 --- a/Makefile +++ b/Makefile @@ -25,16 +25,27 @@ compile: ## Check for byte-compiler errors | grep . && exit 1 || true ;\ done -.PHONY: test -test: ## Run all defined test cases. - @echo "[test] Running all test cases" +.PHONY: docker-build +docker-build: ## Create a build image for running tests + @echo "[docker] Building docker image" @docker build -t flymake-collection-test ./tests/checkers + +DOCKER_COMMAND := bash +DOCKER_FLAGS := -it +.PHONY: docker +docker: docker-build ## Run a command in the built docker-image. @docker run \ --rm \ - --volume "$$(pwd)":/src:ro \ - --volume "$$(pwd)/tests/checkers":/test:ro \ + $(DOCKER_FLAGS) \ + --workdir /workspaces/flymake-collection \ + --volume "$$(pwd)":/workspaces/flymake-collection:ro \ flymake-collection-test \ - sh -c 'find /test/test-cases/ -iname \*.yml | parallel -I{} chronic /test/run-test-case {}' + $(DOCKER_COMMAND) + +.PHONY: test +test: ## Run all defined test cases. + @echo "[test] Running all test cases" + @find ./tests/checkers/test-cases/ -iname '*.yml' | parallel -I{} chronic ./tests/checkers/run-test-case {} .PHONY: clean clean: ## Remove build artifacts diff --git a/tests/checkers/Dockerfile b/tests/checkers/Dockerfile index 559a6cb11b..1c484624ed 100644 --- a/tests/checkers/Dockerfile +++ b/tests/checkers/Dockerfile @@ -29,21 +29,29 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* $(pwd)/* +# Install the latest available version of flymake for these tests. +RUN cd "$(mktemp -d)" && \ + git clone https://github.com/emacs-straight/flymake.git . && \ + mkdir /tmp/emacs && \ + cp flymake.el /etc/emacs/flymake.el && \ + rm -rf "$(pwd)" + +# Add a user for the dev-container workflow and dev dependencies. +ARG USERNAME=devcontainer +ARG USER_UID=1000 +ARG USER_GID=$USER_UID +RUN groupadd --gid $USER_GID $USERNAME && \ + useradd --uid $USER_UID --gid $USER_GID -m $USERNAME +USER root + +# Run installers for all available linters WORKDIR /build +ARG LINTERS="*" COPY installers /build/installers RUN apt-get update && \ apt-get install -y \ parallel python3.8 python3-pip moreutils git && \ python3.8 -m pip install pyyaml && \ - find installers/ -type f -iname '*.bash' -exec {} \; && \ + find installers/ -type f -iname "$LINTERS.bash" -exec {} \; && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* - -# Install the latest available version of flymake for these tests. -RUN cd "$(mktemp -d)" && \ - git clone https://github.com/emacs-straight/flymake.git . && \ - mkdir /tmp/emacs && \ - cp flymake.el /etc/emacs/flymake.el && \ - rm -rf "$(pwd)" - -WORKDIR /src diff --git a/tests/checkers/run-test-case b/tests/checkers/run-test-case index 5e309f07bc..ed5af04da1 100755 --- a/tests/checkers/run-test-case +++ b/tests/checkers/run-test-case @@ -1,4 +1,4 @@ -#!/usr/bin/env python3.8 +#!/usr/bin/env python3 """Test case runner for flymake-collection. """ import json @@ -74,8 +74,8 @@ def run_flymake(src: pathlib.Path, checker: str) -> Optional[List[TestLint]]: (require 'flymake) (require 'json) -(add-to-list 'load-path "/src/src") -(add-to-list 'load-path "/src/src/checkers") +(add-to-list 'load-path "/workspaces/flymake-collection/src") +(add-to-list 'load-path "/workspaces/flymake-collection/src/checkers") (require (intern "{checker}") "{checker}.el") (setq src (find-file-literally "{src}")