Skip to content

Commit 2c51cae

Browse files
committed
Update repository structure for new GitHub repository
0 parents  commit 2c51cae

50 files changed

Lines changed: 4359 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cobra.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
author: Simon Emms <simon@simonemms.com>
2+
license: Apache-2.0
3+
useViper: false

.commitlintrc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
extends:
2+
- "@commitlint/config-conventional"

.cruft.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"template": "https://github.com/mrsimonemms/new",
3+
"commit": "d59cbeb8197a550198ea946e4013da63251d8c3c",
4+
"checkout": null,
5+
"context": {
6+
"cookiecutter": {
7+
"project_name": "devpod-provider-hetzner",
8+
"description": "DevPod on Hetzner",
9+
"author": "Simon Emms <simon@simonemms.com>",
10+
"repo": "github.com/mrsimonemms/devpod-provider-hetzner",
11+
"use_viper": false,
12+
"_template": "https://github.com/mrsimonemms/new",
13+
"_commit": "d59cbeb8197a550198ea946e4013da63251d8c3c"
14+
}
15+
},
16+
"directory": "golang-cobra",
17+
"skip": [
18+
".git"
19+
]
20+
}

.devcontainer/devcontainer.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "devcontainer",
3+
"image": "ghcr.io/mrsimonemms/devcontainers/full",
4+
"features": {
5+
"ghcr.io/mrsimonemms/devcontainers/cobra-cli:0": {},
6+
"ghcr.io/devcontainers-extra/features/gh-release:1": {
7+
"repo": "hetznercloud/cli",
8+
"binaryNames": "hcloud"
9+
}
10+
},
11+
"customizations": {
12+
"vscode": {
13+
"settings": {},
14+
"extensions": [
15+
"donjayamanne.git-extension-pack",
16+
"EditorConfig.EditorConfig",
17+
"waderyan.gitblame",
18+
"GitHub.vscode-github-actions"
19+
]
20+
}
21+
},
22+
"postStartCommand": {
23+
"copy-cobra": "ln -s $PWD/.cobra.yaml $HOME/.cobra.yaml",
24+
"ensure-envrc": "touch .envrc"
25+
},
26+
"containerEnv": {
27+
"DEVPOD_LOG_LEVEL": "debug",
28+
"GIT_REPO": "github.com/mrsimonemms/devpod-provider-hetzner",
29+
"DISK_IMAGE": "docker-ce",
30+
"DISK_SIZE": "30",
31+
"MACHINE_ID": "some-machine-id",
32+
"MACHINE_FOLDER": "/home/vscode/.ssh",
33+
"MACHINE_TYPE": "cx22",
34+
"REGION": "nbg1",
35+
"HCLOUD_TOKEN": ""
36+
}
37+
}

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.go]
13+
indent_style = tab
14+
indent_size = 4
15+
16+
[Makefile]
17+
indent_style = tab
18+
indent_size = 4

.github/workflows/build.yml

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
name: Build
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags:
7+
- "v*.*.*"
8+
pull_request:
9+
branches:
10+
- main
11+
workflow_dispatch:
12+
permissions:
13+
contents: write
14+
packages: write
15+
pull-requests: read
16+
jobs:
17+
commitlint:
18+
runs-on: ubuntu-latest
19+
env:
20+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0 # fetch-depth is required
25+
26+
- uses: wagoid/commitlint-github-action@v6
27+
28+
test:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0 # Required for pre-commit to be able scan history
34+
35+
- name: Set up Go
36+
uses: actions/setup-go@v5
37+
with:
38+
go-version-file: go.mod
39+
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: 3.x
43+
44+
- name: Install dependencies
45+
run: go install ./...
46+
47+
- name: go-vet
48+
run: go vet -v ./...
49+
50+
- name: go-test
51+
run: go test -v ./...
52+
53+
- name: golangci-lint
54+
uses: golangci/golangci-lint-action@v6
55+
56+
- uses: pre-commit/action@v3.0.1
57+
58+
e2e:
59+
runs-on: ubuntu-latest
60+
env:
61+
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
62+
DISK_IMAGE: docker-ce
63+
DISK_SIZE: "30"
64+
MACHINE_ID: test-${{ github.run_id }}
65+
MACHINE_FOLDER: ${{ github.workspace }}./ssh
66+
MACHINE_TYPE: "cx22"
67+
REGION: "nbg1"
68+
SSH_KEY_PUB: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK2sB1n570BgGJ3+I0Dgzxhlf9ukc+Hp+C/zsIH4J8Xm vscode@df47ba471beb"
69+
SSH_KEY: ${{ secrets.SSH_KEY }}
70+
steps:
71+
- uses: actions/checkout@v4
72+
73+
- uses: hetznercloud/setup-hcloud@v1
74+
75+
- name: Set up SSH keys
76+
run: |
77+
mkdir -p ${MACHINE_FOLDER}
78+
echo ${SSH_KEY_PUB} > ${MACHINE_FOLDER}/sshkey.pub
79+
echo ${SSH_KEY} > ${MACHINE_FOLDER}/sshkey
80+
ls -la ${MACHINE_FOLDER}
81+
82+
- name: Set up Go
83+
uses: actions/setup-go@v5
84+
with:
85+
go-version-file: go.mod
86+
87+
- run: go build -o provider .
88+
89+
- name: Create command
90+
run: ./provider create
91+
92+
- name: Run command
93+
env:
94+
COMMAND: hostname
95+
run: ./provider command | grep ${MACHINE_ID}
96+
97+
- name: Stop command
98+
run: ./provider stop
99+
100+
- name: Start command
101+
run: ./provider start
102+
103+
- name: Run command
104+
env:
105+
COMMAND: hostname
106+
run: ./provider command | grep ${MACHINE_ID}
107+
108+
- name: Delete command
109+
run: ./provider delete
110+
111+
# This can fail due to resources failing to detach properly
112+
- name: Ensure destruction
113+
if: ${{ always() }}
114+
uses: nick-fields/retry@v3
115+
with:
116+
timeout_minutes: 10
117+
max_attempts: 3
118+
command: ./hack/hcloud_destroy.sh
119+
120+
build:
121+
runs-on: ubuntu-latest
122+
outputs:
123+
is_tag: ${{ steps.branch-name.outputs.is_tag }}
124+
env:
125+
# Used to get default HCloud values
126+
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
127+
steps:
128+
- uses: actions/checkout@v4
129+
with:
130+
fetch-depth: 0
131+
132+
- name: Set up Go
133+
uses: actions/setup-go@v5
134+
with:
135+
go-version-file: go.mod
136+
137+
- run: go version
138+
139+
- name: Get branch names
140+
id: branch-name
141+
uses: tj-actions/branch-names@v8
142+
with:
143+
strip_tag_prefix: v
144+
145+
- name: Generate version info
146+
id: version
147+
run: |
148+
if [ "${{ steps.branch-name.outputs.is_tag }}" = "true" ];
149+
then
150+
echo "version=${{ steps.branch-name.outputs.tag }}" >> "$GITHUB_OUTPUT"
151+
else
152+
echo "version=development" >> "$GITHUB_OUTPUT"
153+
fi
154+
155+
echo "commit_id=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
156+
echo "gitRepo=github.com/${GITHUB_REPOSITORY}" >> "$GITHUB_OUTPUT"
157+
158+
- name: Compile binaries
159+
run: ./hack/build.sh
160+
env:
161+
GIT_COMMIT: ${{ steps.version.outputs.commit_id }}
162+
GIT_REPO: ${{ steps.version.outputs.gitRepo }}
163+
RELEASE_VERSION: ${{ steps.version.outputs.version }}
164+
165+
- uses: actions/upload-artifact@v4
166+
with:
167+
name: dist
168+
path: dist/
169+
170+
publish:
171+
runs-on: ubuntu-latest
172+
needs:
173+
- build
174+
- commitlint
175+
- e2e
176+
- test
177+
if: needs.build.outputs.is_tag == 'true'
178+
steps:
179+
- uses: actions/download-artifact@v4
180+
with:
181+
name: dist
182+
path: dist/
183+
184+
- uses: actions/setup-node@v4
185+
186+
- name: Build Changelog
187+
id: github_release
188+
uses: mikepenz/release-changelog-builder-action@v3
189+
env:
190+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
191+
192+
- name: Release
193+
uses: softprops/action-gh-release@v1
194+
with:
195+
body: ${{ steps.github_release.outputs.changelog }}
196+
files: dist/*

.github/workflows/stale.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Close stale issues and PRs
2+
on:
3+
schedule:
4+
- cron: 0 2 * * *
5+
workflow_dispatch:
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
issues: write
12+
pull-requests: write
13+
steps:
14+
- uses: actions/stale@v9
15+
with:
16+
days-before-stale: 60
17+
days-before-close: 7
18+
stale-issue-message: |
19+
This issue is stale because it has been open 60 days with no activity. It will be closed in 7 days if no further activity.
20+
stale-pr-message: |
21+
This PR is stale because it has been open 60 days with no activity. It will be closed in 7 days if no further activity.

0 commit comments

Comments
 (0)