Skip to content

Commit 9b91437

Browse files
committed
Add Woodpecker CI plugin
1 parent aefa886 commit 9b91437

File tree

29 files changed

+7630
-0
lines changed

29 files changed

+7630
-0
lines changed

.forgejo/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Forgejo Actions Placeholder
2+
3+
This directory exists to prevent Forgejo from falling back to GitHub Actions workflows.
4+
5+
## Why is this directory empty?
6+
7+
This project uses **Woodpecker CI** (configured in `.woodpecker.yml`), not Forgejo Actions.
8+
9+
When Forgejo detects this directory, it will **not** attempt to use any GitHub Actions workflows that might exist in `.github/workflows/`. Without this directory, Forgejo would try to execute GitHub Actions as a fallback, which is not desired for this project.
10+
11+
## Note
12+
13+
- **DO NOT DELETE** this directory unless you want to enable GitHub Actions fallback behavior
14+
- If you want to use Forgejo Actions in the future, place workflow files in `.forgejo/workflows/`
15+
- Current CI system: Woodpecker CI (see `.woodpecker.yml`)

.woodpecker.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Woodpecker CI configuration for testing the woodpecker-plugin
2+
# This config is only for testing purposes in local Woodpecker CI
3+
4+
when:
5+
event: [push, pull_request, manual]
6+
7+
steps:
8+
# Check code formatting
9+
- name: format-check
10+
image: node:20-alpine
11+
commands:
12+
- cd woodpecker-plugin && npm ci && npm run format-check
13+
14+
# Lint TypeScript code
15+
- name: lint
16+
image: node:20-alpine
17+
commands:
18+
- cd woodpecker-plugin && npm ci && npm run lint
19+
20+
# Install dependencies and build TypeScript
21+
- name: build-typescript
22+
image: node:20-alpine
23+
commands:
24+
- cd common && npm ci && npm run build
25+
- cd ../woodpecker-plugin && npm ci && npm run build
26+
depends_on:
27+
- format-check
28+
- lint
29+
30+
# Run unit tests for env-parser
31+
- name: test-env-parser
32+
image: node:20-alpine
33+
commands:
34+
- cd woodpecker-plugin && npm test
35+
depends_on:
36+
- build-typescript
37+
38+
# Build the plugin Docker image
39+
- name: build-plugin-image
40+
image: docker:latest
41+
commands:
42+
- docker build -f woodpecker-plugin/Dockerfile -t woodpecker-plugin:test .
43+
volumes:
44+
- /var/run/docker.sock:/var/run/docker.sock
45+
depends_on:
46+
- test-env-parser
47+
48+
# Test scenario 1: simple-node (image-based)
49+
- name: test-simple-node-build
50+
image: woodpecker-plugin:test
51+
settings:
52+
sub_folder: woodpecker-plugin-tests/simple-node
53+
image_name: test-simple-node
54+
image_tag: test
55+
volumes:
56+
- /var/run/docker.sock:/var/run/docker.sock
57+
depends_on:
58+
- build-plugin-image
59+
60+
- name: test-simple-node-run
61+
image: test-simple-node:test
62+
commands:
63+
- echo "Testing simple-node DevContainer!"
64+
- node --version
65+
- npm --version
66+
depends_on:
67+
- test-simple-node-build
68+
69+
- name: test-simple-node-run-cmd
70+
image: woodpecker-plugin:test
71+
settings:
72+
sub_folder: woodpecker-plugin-tests/simple-node
73+
run_cmd: echo "run_cmd test!" && node --version
74+
volumes:
75+
- /var/run/docker.sock:/var/run/docker.sock
76+
depends_on:
77+
- test-simple-node-build
78+
79+
# Test scenario 2: with-dockerfile
80+
- name: test-dockerfile-build
81+
image: woodpecker-plugin:test
82+
settings:
83+
sub_folder: woodpecker-plugin-tests/with-dockerfile
84+
image_name: test-dockerfile
85+
image_tag: test
86+
volumes:
87+
- /var/run/docker.sock:/var/run/docker.sock
88+
depends_on:
89+
- build-plugin-image
90+
91+
- name: test-dockerfile-run
92+
image: test-dockerfile:test
93+
commands:
94+
- echo "Testing with-dockerfile DevContainer!"
95+
- node --version
96+
- git --version
97+
depends_on:
98+
- test-dockerfile-build
99+
100+
# Test scenario 3: with-features (features + build args)
101+
- name: test-features-build
102+
image: woodpecker-plugin:test
103+
settings:
104+
sub_folder: woodpecker-plugin-tests/with-features
105+
image_name: test-features
106+
image_tag: test
107+
volumes:
108+
- /var/run/docker.sock:/var/run/docker.sock
109+
depends_on:
110+
- build-plugin-image
111+
112+
- name: test-features-run
113+
image: test-features:test
114+
commands:
115+
- echo "Testing with-features DevContainer!"
116+
- node --version
117+
- git --version
118+
- python3 --version
119+
depends_on:
120+
- test-features-build
121+
122+
- name: test-features-run-cmd
123+
image: woodpecker-plugin:test
124+
settings:
125+
sub_folder: woodpecker-plugin-tests/with-features
126+
run_cmd: echo "Features run_cmd test!" && node --version && git --version && python3 --version
127+
volumes:
128+
- /var/run/docker.sock:/var/run/docker.sock
129+
depends_on:
130+
- test-features-build

scripts/build-woodpecker-docker.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
set -e
3+
4+
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
5+
repo_root="$script_dir/.."
6+
7+
# Default values
8+
IMAGE_NAME="${IMAGE_NAME:-devcontainer-woodpecker}"
9+
IMAGE_TAG="${IMAGE_TAG:-local}"
10+
PLATFORMS="${PLATFORMS:-linux/amd64}"
11+
PUSH="${PUSH:-false}"
12+
13+
echo "Building Woodpecker Plugin Docker Image"
14+
echo "========================================"
15+
echo "Image: ${IMAGE_NAME}:${IMAGE_TAG}"
16+
echo "Platforms: ${PLATFORMS}"
17+
echo "Push: ${PUSH}"
18+
echo ""
19+
20+
cd "$repo_root"
21+
22+
if [ "$PUSH" = "true" ]; then
23+
echo "Building and pushing multi-platform image..."
24+
docker buildx build \
25+
--platform "$PLATFORMS" \
26+
-f woodpecker-plugin/Dockerfile \
27+
-t "${IMAGE_NAME}:${IMAGE_TAG}" \
28+
--push \
29+
.
30+
else
31+
echo "Building image for local use..."
32+
docker build \
33+
-f woodpecker-plugin/Dockerfile \
34+
-t "${IMAGE_NAME}:${IMAGE_TAG}" \
35+
.
36+
fi
37+
38+
echo ""
39+
echo "==> Docker image built successfully!"
40+
echo " Image: ${IMAGE_NAME}:${IMAGE_TAG}"
41+
echo ""
42+
echo "To test the image locally, run:"
43+
echo " docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \\"
44+
echo " -v \$(pwd):/workspace \\"
45+
echo " -e PLUGIN_RUN_CMD='echo Hello from Dev Container' \\"
46+
echo " -e CI_WORKSPACE=/workspace \\"
47+
echo " ${IMAGE_NAME}:${IMAGE_TAG}"

scripts/build-woodpecker.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -e
3+
4+
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
5+
6+
echo "Building Woodpecker Plugin..."
7+
echo ""
8+
9+
echo "==> Building common"
10+
cd "$script_dir/../common"
11+
npm install
12+
npm run build
13+
14+
echo ""
15+
echo "==> Building woodpecker-plugin"
16+
cd "$script_dir/../woodpecker-plugin"
17+
npm install
18+
npm run build
19+
20+
echo ""
21+
echo "==> Woodpecker plugin build completed successfully!"

woodpecker-plugin-tests/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Woodpecker Plugin Tests
2+
3+
This directory contains integration test scenarios for the woodpecker-plugin.
4+
5+
## Test Scenarios
6+
7+
### `simple-node/`
8+
Basic DevContainer using a pre-built image from Docker Hub.
9+
- Tests: Image-based DevContainer, basic commands
10+
11+
### `with-dockerfile/`
12+
DevContainer with a custom Dockerfile.
13+
- Tests: Dockerfile-based builds, custom package installation
14+
15+
### `with-features/`
16+
DevContainer with features and build arguments.
17+
- Tests: Dockerfile with build args (VARIANT, WELCOME_MESSAGE), DevContainer features (git, python), postCreateCommand
18+
19+
## Running Tests
20+
21+
Tests are executed in the main `.woodpecker.yml` pipeline:
22+
1. Plugin builds the DevContainer image for each scenario
23+
2. Commands are executed inside the built DevContainer
24+
3. Results verify plugin functionality
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "Woodpecker Plugin Test",
3+
"image": "mcr.microsoft.com/devcontainers/javascript-node:20",
4+
"features": {},
5+
"customizations": {
6+
"vscode": {
7+
"extensions": []
8+
}
9+
},
10+
"postCreateCommand": "echo 'DevContainer initialized successfully' && node --version && npm --version"
11+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM node:20-alpine
2+
3+
RUN apk add --no-cache git
4+
5+
USER node
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "Node with Dockerfile",
3+
"dockerFile": "Dockerfile",
4+
"customizations": {
5+
"vscode": {
6+
"extensions": []
7+
}
8+
},
9+
"postCreateCommand": "echo 'DevContainer with Dockerfile initialized!' && node --version && git --version"
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ARG VARIANT=20
2+
FROM node:${VARIANT}-bookworm
3+
4+
ARG WELCOME_MESSAGE="DevContainer with features!"
5+
6+
RUN echo "Building with message: ${WELCOME_MESSAGE}"
7+
8+
USER node
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "Node with Features",
3+
"dockerFile": "Dockerfile",
4+
"build": {
5+
"args": {
6+
"VARIANT": "20",
7+
"WELCOME_MESSAGE": "Hello from Woodpecker CI!"
8+
}
9+
},
10+
"features": {
11+
"ghcr.io/devcontainers/features/git:1": {
12+
"version": "latest"
13+
},
14+
"ghcr.io/devcontainers/features/python:1": {
15+
"version": "3.11"
16+
}
17+
},
18+
"customizations": {
19+
"vscode": {
20+
"extensions": []
21+
}
22+
},
23+
"postCreateCommand": "echo 'Post-create command executed!' && node --version && git --version && python3 --version"
24+
}

0 commit comments

Comments
 (0)