Skip to content

Commit cfbfeb1

Browse files
committed
feat(ci-utility): add ci-utility feature
1 parent 38a49df commit cfbfeb1

11 files changed

Lines changed: 239 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
feature: [
1818
"browsers",
1919
"build-essential",
20+
"ci-utility",
2021
"docker-out",
2122
"git-lfs",
2223
"go",

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Below is a list with included features, click on the link for more details.
1717
| --- | --- |
1818
| [browsers](./features/src/browsers/README.md) | A package which installs various browsers. |
1919
| [build-essential](./features/src/build-essential/README.md) | Installs essential build tools (e.g., gcc, g++, make, libc-dev) for compiling C/C++ and |
20+
| [ci-utility](./features/src/ci-utility/README.md) | A feature which installs common CI/CD utilities |
2021
| [docker-out](./features/src/docker-out/README.md) | A feature which installs the Docker client and re-uses the host socket. |
2122
| [git-lfs](./features/src/git-lfs/README.md) | A feature which installs Git LFS. |
2223
| [go](./features/src/go/README.md) | A feature which installs Go. |

build/build.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
var featureList = []string{
2323
"browsers",
2424
"build-essential",
25+
"ci-utility",
2526
"docker-out",
2627
"git-lfs",
2728
"go",
@@ -74,6 +75,17 @@ func init() {
7475
return publishFeature("build-essential")
7576
})
7677

78+
////////// ci-utility
79+
gotaskr.Task("Feature:ci-utility:Package", func() error {
80+
return packageFeature("ci-utility")
81+
})
82+
gotaskr.Task("Feature:ci-utility:Test", func() error {
83+
return testFeature("ci-utility")
84+
})
85+
gotaskr.Task("Feature:ci-utility:Publish", func() error {
86+
return publishFeature("ci-utility")
87+
})
88+
7789
////////// docker-out
7890
gotaskr.Task("Feature:docker-out:Package", func() error {
7991
return packageFeature("docker-out")

features/src/ci-utility/NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Notes
2+
3+
### System Compatibility
4+
5+
Debian (Bookworm, Trixie), Ubuntu

features/src/ci-utility/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# CI Utility (ci-utility)
2+
3+
A package which installs various ci utility tools.
4+
5+
## Example Usage
6+
7+
```json
8+
"features": {
9+
"ghcr.io/postfinance/devcontainer-features/ci-utility:0.1.0": {
10+
"yqVersion": "system-default",
11+
"gettextbaseVersion": "system-default",
12+
"yamllintVersion": "system-default",
13+
"gitlfsVersion": "system-default",
14+
"sshpassVersion": "system-default"
15+
}
16+
}
17+
```
18+
19+
## Options
20+
21+
| Option | Description | Type | Default Value | Proposals |
22+
|-----|-----|-----|-----|-----|
23+
| yqVersion | The version of yq to install. | string | system-default | system-default, none |
24+
| gettextbaseVersion | The version of gettext-base to install. | string | system-default | system-default, none |
25+
| yamllintVersion | The version of yamllint to install. | string | system-default | system-default, none |
26+
| gitlfsVersion | The version of git-lfs to install. | string | system-default | system-default, none |
27+
| sshpassVersion | The version of sshpass to install. | string | system-default | system-default, none |
28+
29+
## Notes
30+
31+
### System Compatibility
32+
33+
Debian (Bookworm, Trixie), Ubuntu
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"id": "ci-utility",
3+
"version": "0.1.0",
4+
"name": "CI Utility",
5+
"description": "A package which installs various ci utility tools.",
6+
"options": {
7+
"yqVersion": {
8+
"type": "string",
9+
"proposals": [
10+
"system-default",
11+
"none"
12+
],
13+
"default": "system-default",
14+
"description": "The version of yq to install."
15+
},
16+
"gettextbaseVersion": {
17+
"type": "string",
18+
"proposals": [
19+
"system-default",
20+
"none"
21+
],
22+
"default": "system-default",
23+
"description": "The version of gettext-base to install."
24+
},
25+
"yamllintVersion": {
26+
"type": "string",
27+
"proposals": [
28+
"system-default",
29+
"none"
30+
],
31+
"default": "system-default",
32+
"description": "The version of yamllint to install."
33+
},
34+
"gitlfsVersion": {
35+
"type": "string",
36+
"proposals": [
37+
"system-default",
38+
"none"
39+
],
40+
"default": "system-default",
41+
"description": "The version of git-lfs to install."
42+
},
43+
"sshpassVersion": {
44+
"type": "string",
45+
"proposals": [
46+
"system-default",
47+
"none"
48+
],
49+
"default": "system-default",
50+
"description": "The version of sshpass to install."
51+
}
52+
}
53+
}

features/src/ci-utility/install.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
. ./functions.sh
2+
3+
"./installer_$(detect_arch)" \
4+
-yqVersion="${VERSION:-"system-default"}" \
5+
-gettextbaseVersion="${VERSION:-"system-default"}" \
6+
-yamllintVersion="${VERSION:-"system-default"}" \
7+
-gitlfsVersion="${VERSION:-"system-default"}" \
8+
-sshpassVersion="${VERSION:-"system-default"}"
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package main
2+
3+
import (
4+
"builder/installer"
5+
"flag"
6+
"fmt"
7+
"os"
8+
9+
"github.com/roemer/gover"
10+
)
11+
12+
// ////////
13+
// Main
14+
// ////////
15+
16+
func main() {
17+
if err := runMain(); err != nil {
18+
fmt.Printf("Error: %v\n", err)
19+
os.Exit(1)
20+
}
21+
}
22+
23+
func runMain() error {
24+
// Create and process the feature
25+
yqVersion := flag.String("yqVersion", "system-default", "The version of yq to install.")
26+
gettextbaseVersion := flag.String("gettextbaseVersion", "system-default", "The version of gettext-base to install.")
27+
yamllintVersion := flag.String("yamllintVersion", "system-default", "The version of yamllint to install.")
28+
gitlfsVersion := flag.String("gitlfsVersion", "system-default", "The version of git-lfs to install.")
29+
sshpassVersion := flag.String("sshpassVersion", "system-default", "The version of sshpass to install.")
30+
31+
feature := installer.NewFeature("CI Utility", true,
32+
&yqComponent{
33+
ComponentBase: installer.NewComponentBase("yq", *yqVersion),
34+
},
35+
&gettextbaseComponent{
36+
ComponentBase: installer.NewComponentBase("gettext-base", *gettextbaseVersion),
37+
},
38+
&yamllintComponent{
39+
ComponentBase: installer.NewComponentBase("yamllint", *yamllintVersion),
40+
},
41+
&gitlfsComponent{
42+
ComponentBase: installer.NewComponentBase("git-lfs", *gitlfsVersion),
43+
},
44+
&sshpassComponent{
45+
ComponentBase: installer.NewComponentBase("sshpass", *sshpassVersion),
46+
},
47+
)
48+
return feature.Process()
49+
}
50+
51+
// ////////
52+
// Implementation
53+
// ////////
54+
55+
type yqComponent struct {
56+
*installer.ComponentBase
57+
}
58+
59+
func (c *yqComponent) InstallVersion(*gover.Version) error {
60+
return installer.Tools.Apt.InstallDependencies("yq")
61+
}
62+
63+
type gettextbaseComponent struct {
64+
*installer.ComponentBase
65+
}
66+
67+
func (c *gettextbaseComponent) InstallVersion(*gover.Version) error {
68+
return installer.Tools.Apt.InstallDependencies("gettext-base")
69+
}
70+
71+
type yamllintComponent struct {
72+
*installer.ComponentBase
73+
}
74+
75+
func (c *yamllintComponent) InstallVersion(*gover.Version) error {
76+
return installer.Tools.Apt.InstallDependencies("yamllint")
77+
}
78+
79+
type gitlfsComponent struct {
80+
*installer.ComponentBase
81+
}
82+
83+
func (c *gitlfsComponent) InstallVersion(*gover.Version) error {
84+
return installer.Tools.Apt.InstallDependencies("git-lfs")
85+
}
86+
87+
type sshpassComponent struct {
88+
*installer.ComponentBase
89+
}
90+
91+
func (c *sshpassComponent) InstallVersion(*gover.Version) error {
92+
return installer.Tools.Apt.InstallDependencies("sshpass")
93+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -e
3+
4+
[[ -f "$(dirname "$0")/../functions.sh" ]] && source "$(dirname "$0")/../functions.sh"
5+
[[ -f "$(dirname "$0")/functions.sh" ]] && source "$(dirname "$0")/functions.sh"
6+
7+
check_command_exists "yq"
8+
check_command_exists "yamllint"
9+
check_command_exists "git-lfs"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"default": {
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"options": [
6+
"--add-host=host.docker.internal:host-gateway"
7+
]
8+
},
9+
"features": {
10+
"./ci-utility": {
11+
"yqVersion": "system-default",
12+
"gettextbaseVersion": "system-default",
13+
"yamllintVersion": "system-default",
14+
"gitlfsVersion": "system-default",
15+
"sshpassVersion": "system-default"
16+
}
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)