Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…to FEAT-linode-driver
  • Loading branch information
guisea committed Jan 28, 2024
2 parents f191d7a + c25ccb4 commit c32f380
Show file tree
Hide file tree
Showing 21 changed files with 392 additions and 157 deletions.
2 changes: 2 additions & 0 deletions .hadolint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignored:
- DL3018 # pin versions in Dockerfile
143 changes: 143 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# markdownlint YAML configuration
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml

# Default state for all rules
default: true

# Path to configuration file to extend
extends: null

# MD003/heading-style/header-style - Heading style
MD003:
# Heading style
style: 'atx'

# MD004/ul-style - Unordered list style
MD004:
style: 'dash'

# MD007/ul-indent - Unordered list indentation
MD007:
# Spaces for indent
indent: 2
# Whether to indent the first level of the list
start_indented: false

# MD009/no-trailing-spaces - Trailing spaces
MD009:
# Spaces for line break
br_spaces: 2
# Allow spaces for empty lines in list items
list_item_empty_lines: false
# Include unnecessary breaks
strict: false

# MD010/no-hard-tabs - Hard tabs
MD010:
# Include code blocks
code_blocks: true

# MD012/no-multiple-blanks - Multiple consecutive blank lines
MD012:
# Consecutive blank lines
maximum: 1

# MD013/line-length - Line length
MD013:
# Number of characters
line_length: 500
# Number of characters for headings
heading_line_length: 100
# Number of characters for code blocks
code_block_line_length: 80
# Include code blocks
code_blocks: false
# Include tables
tables: false
# Include headings
headings: true
# Include headings
headers: true
# Strict length checking
strict: false
# Stern length checking
stern: false

# MD022/blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines
MD022:
# Blank lines above heading
lines_above: 1
# Blank lines below heading
lines_below: 1

# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
MD024:
# Only check sibling headings
allow_different_nesting: true

# MD025/single-title/single-h1 - Multiple top-level headings in the same document
MD025:
# Heading level
level: 1
# RegExp for matching title in front matter
front_matter_title: "^\\s*title\\s*[:=]"

# MD026/no-trailing-punctuation - Trailing punctuation in heading
MD026:
# Punctuation characters
punctuation: '.,;:!。,;:!'

# MD029/ol-prefix - Ordered list item prefix
MD029:
# List style
style: 'one_or_ordered'

# MD030/list-marker-space - Spaces after list markers
MD030:
# Spaces for single-line unordered list items
ul_single: 1
# Spaces for single-line ordered list items
ol_single: 1
# Spaces for multi-line unordered list items
ul_multi: 1
# Spaces for multi-line ordered list items
ol_multi: 1

# MD033/no-inline-html - Inline HTML
MD033:
# Allowed elements
allowed_elements: [details, summary, img, a, br, p]

# MD035/hr-style - Horizontal rule style
MD035:
# Horizontal rule style
style: '---'

# MD036/no-emphasis-as-heading/no-emphasis-as-header - Emphasis used instead of a heading
MD036:
# Punctuation characters
punctuation: '.,;:!?。,;:!?'

# MD041/first-line-heading/first-line-h1 - First line in a file should be a top-level heading
MD041:
# Heading level
level: 1
# RegExp for matching title in front matter
front_matter_title: "^\\s*title\\s*[:=]"

# MD044/proper-names - Proper names should have the correct capitalization
MD044:
# List of proper names
# names:
# Include code blocks
code_blocks: false

# MD046/code-block-style - Code block style
MD046:
# Block style
style: 'fenced'

# MD048/code-fence-style - Code fence style
MD048:
# Code fence syle
style: 'backtick'
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
repos:
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/golangci/golangci-lint
rev: v1.55.2
hooks:
- id: golangci-lint
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.38.0
hooks:
- id: markdownlint
- repo: https://github.com/mrtazz/checkmake
rev: 0.2.2
hooks:
- id: checkmake
exclude: '^Dockerfile.make$' # actually a Dockerfile and not a makefile
- repo: https://github.com/hadolint/hadolint
rev: v2.12.1-beta
hooks:
- id: hadolint

ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks [CI SKIP]
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: monthly
# NB: hadolint not included in pre-commit.ci
skip: [check-hooks-apply, check-useless-excludes, hadolint]
submodules: false
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120,
"tabWidth": 2,
"endOfLine": "lf"
}
2 changes: 1 addition & 1 deletion .woodpecker/release-helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ when:

steps:
release:
image: woodpeckerci/plugin-ready-release-go
image: woodpeckerci/plugin-ready-release-go:1.0.3
pull: true
settings:
git_email: woodpecker-bot@obermui.de
Expand Down
18 changes: 10 additions & 8 deletions .woodpecker/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ when:

steps:
dryrun:
image: woodpeckerci/plugin-docker-buildx
image: woodpeckerci/plugin-docker-buildx:3.0.0
settings:
dockerfile: Containerfile
dockerfile: Dockerfile
dry_run: true
repo: woodpeckerci/autoscaler
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le
Expand All @@ -16,24 +16,26 @@ steps:
event: pull_request

publish-next:
image: woodpeckerci/plugin-docker-buildx
image: woodpeckerci/plugin-docker-buildx:3.0.0
settings:
dockerfile: Containerfile
dockerfile: Dockerfile
repo: woodpeckerci/autoscaler
platforms: linux/arm/v7,linux/arm64,linux/amd64,linux/ppc64le
tag: next
secrets: [docker_username, docker_password]
username: woodpeckerbot
secrets: [docker_password]
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
event: push

publish-tag:
image: woodpeckerci/plugin-docker-buildx
image: woodpeckerci/plugin-docker-buildx:3.0.0
settings:
dockerfile: Containerfile
dockerfile: Dockerfile
repo: woodpeckerci/autoscaler
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le
tag: [latest, "${CI_COMMIT_TAG}"]
secrets: [docker_username, docker_password]
username: woodpeckerbot
secrets: [docker_password]
when:
event: tag
4 changes: 2 additions & 2 deletions .woodpecker/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ when:
branch: ${CI_REPO_DEFAULT_BRANCH}

variables:
- &golang_image "golang:1.20.2"
- &golang_image "golang:1.21.6"
- &when
- path: &when_path # related config files
- ".woodpecker/test.yml"
Expand All @@ -29,7 +29,7 @@ steps:
when: *when

lint-editorconfig:
image: mstruebing/editorconfig-checker
image: mstruebing/editorconfig-checker:2.7.2
group: test

test:
Expand Down
2 changes: 1 addition & 1 deletion Containerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.20 AS build
FROM --platform=$BUILDPLATFORM golang:1.21 AS build

WORKDIR /src
COPY . .
Expand Down
4 changes: 2 additions & 2 deletions Containerfile.make → Dockerfile.make
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# docker build --rm -f docker/Dockerfile.make -t woodpecker/make:local .
FROM golang:1.20-alpine as golang_image
FROM node:18-alpine
FROM golang:1.21-alpine as golang_image
FROM node:21-alpine

RUN apk add --no-cache --update make gcc binutils-gold musl-dev && \
corepack enable
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ else

##@ General

.PHONY: all
all: help

# The help target prints out all targets with their descriptions organized
Expand Down Expand Up @@ -82,16 +83,17 @@ lint: install-tools ## Lint code
@echo "Running golangci-lint"
golangci-lint run --timeout 10m
@echo "Running zerolog linter"
lint github.com/woodpecker-ci/autoscaler/cmd/woodpecker-autoscaler
lint go.woodpecker-ci.org/autoscaler/cmd/woodpecker-autoscaler

test-autoscaler: ## Test autoscaler code
go test -race -cover -coverprofile autoscaler-coverage.out -timeout 30s ${GO_PACKAGES}

.PHONY: test
test: test-autoscaler ## Run all tests

##@ Build

build:
CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags '${LDFLAGS}' -o dist/woodpecker-autoscaler github.com/woodpecker-ci/autoscaler/cmd/woodpecker-autoscaler
CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags '${LDFLAGS}' -o dist/woodpecker-autoscaler go.woodpecker-ci.org/autoscaler/cmd/woodpecker-autoscaler

endif
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ services:
- WOODEPCKER_GRPC_ADDR=https://grpc.your-woodpecker-server.tld # the grpc address of your woodpecker server, publicly accessible from the agents
- WOODEPCKER_GRPC_SECURE=true
- WOODPECKER_AGENT_ENV= # optional environment variables to pass to the agents
- WOODPECKER_PROVIDER=hetznercloud # set the provider, you can find all the available ones down below
- WOODPECKER_HETZNERCLOUD_API_TOKEN=${WOODPECKER_HETZNERCLOUD_API_TOKEN} # your api token for the Hetzner cloud
```
Expand Down
10 changes: 5 additions & 5 deletions cmd/woodpecker-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"

"github.com/woodpecker-ci/autoscaler/config"
"github.com/woodpecker-ci/autoscaler/engine"
"github.com/woodpecker-ci/autoscaler/providers/hetznercloud"
"github.com/woodpecker-ci/autoscaler/providers/linode"
"github.com/woodpecker-ci/autoscaler/server"
"go.woodpecker-ci.org/autoscaler/config"
"go.woodpecker-ci.org/autoscaler/engine"
"go.woodpecker-ci.org/autoscaler/providers/hetznercloud"
"go.woodpecker-ci.org/autoscaler/providers/linode"
"go.woodpecker-ci.org/autoscaler/server"
)

func setupProvider(ctx *cli.Context, config *config.Config) (engine.Provider, error) {
Expand Down
4 changes: 2 additions & 2 deletions engine/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"time"

"github.com/rs/zerolog/log"
"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker"
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"

"github.com/woodpecker-ci/autoscaler/config"
"go.woodpecker-ci.org/autoscaler/config"
)

type Autoscaler struct {
Expand Down
4 changes: 2 additions & 2 deletions engine/autoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

"github.com/franela/goblin"
"github.com/rs/zerolog"
"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker"
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"

"github.com/woodpecker-ci/autoscaler/config"
"go.woodpecker-ci.org/autoscaler/config"
)

type MockClient struct {
Expand Down
Loading

0 comments on commit c32f380

Please sign in to comment.