Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sacloud/[email protected] #74

Merged
merged 3 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2

updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
time: "00:00"
commit-message:
prefix: "ci:"

- package-ecosystem: gomod
directory: /
schedule:
interval: daily
time: "00:00"
commit-message:
prefix: "go:"
13 changes: 9 additions & 4 deletions .github/workflows/publish_dev_docker_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@ jobs:
steps:
-
name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
-
name: Build and push to GitHub Container Registry
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ghcr.io/sacloud/packer:dev
push: true
19 changes: 12 additions & 7 deletions .github/workflows/publish_docker_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,31 @@ jobs:
steps:
-
name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/sacloud/packer
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
-
name: Build and push to GitHub Container Registry
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
tags: ${{ steps.docker_meta.outputs.tags }},ghcr.io/sacloud/packer:latest
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }},ghcr.io/sacloud/packer:latest
push: true
34 changes: 16 additions & 18 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
name: Release

on:
push:
tags: 'v[0-9]+.[0-9]+.[0-9]+'

env:
GOPROXY: https://proxy.golang.org

jobs:
build:
name: build
runs-on: ubuntu-20.04
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Unshallow
run: git fetch --prune --unshallow

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16

- name: Describe plugin
id: plugin_describe
run: echo "::set-output name=api_version::$(go run . describe | jq -r '.api_version')"
go-version: 1.17

- name: Import GPG key
id: import_gpg
uses: paultyng/[email protected]
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git-user-signingkey: true
git-commit-gpgsign: true

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
API_VERSION: ${{ steps.plugin_describe.outputs.api_version }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
56 changes: 41 additions & 15 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,73 @@ on: [push, pull_request]
env:
GOPROXY: https://proxy.golang.org
jobs:
lint:
name: lint
lint-text:
name: lint-text
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Unshallow
run: git fetch --prune --unshallow

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16
go-version: 1.18

- name: Setup tools
run: make tools
run: |
make tools

- name: make lint-text
run: |
make lint-text
lint-go:
name: lint-go
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Unshallow
run: git fetch --prune --unshallow

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Setup tools
run: |
make tools

- name: make lint-go
run: |
make lint-go

- name: make lint
run: make lint
test:
name: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-20.04]
os: [macos-latest, windows-latest, ubuntu-22.04, ubuntu-20.04]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Unshallow
run: git fetch --prune --unshallow

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16
go-version: 1.18

- name: Setup tools
run: make tools
run: |
make tools

- name: make test
run: make test

run: |
make test
2 changes: 2 additions & 0 deletions .textlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LICENSE
dist/
23 changes: 23 additions & 0 deletions .textlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"rules": {
"common-misspellings": true,
"preset-jtf-style": {
"3.1.1.全角文字と半角文字の間": false,
"4.2.7.コロン(:)":false,
"4.3.1.丸かっこ()": false
},
"preset-ja-technical-writing": {
"ja-no-mixed-period": false,
"no-exclamation-question-mark": false,
"sentence-length": {
max:150
},
"max-kanji-continuous-len": {
"max": 7
},
"max-comma": {
max: 4
}
}
}
}
53 changes: 14 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
NAME=sakuracloud
BINARY=packer-plugin-${NAME}
HASHICORP_PACKER_PLUGIN_SDK_VERSION?=$(shell go list -m github.com/hashicorp/packer-plugin-sdk | cut -d " " -f2)
#====================
AUTHOR ?= The sacloud/go-template Authors
COPYRIGHT_YEAR ?= 2022

BIN ?= packer-plugin-sakuracloud

include includes/go/common.mk
include includes/go/single.mk
#====================

TEST?=$$(go list ./... | grep -v vendor)
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
HASHICORP_PACKER_PLUGIN_SDK_VERSION?=$(shell go list -m github.com/hashicorp/packer-plugin-sdk | cut -d " " -f2)

default: lint build
default: fmt generate go-licenses-check goimports lint test

.PHONY: tools
tools: install-packer-sdc
GO111MODULE=off go get golang.org/x/tools/cmd/goimports
GO111MODULE=off go get github.com/client9/misspell/cmd/misspell
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/v1.38.0/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.38.0
tools: dev-tools install-packer-sdc

install-packer-sdc:
go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@${HASHICORP_PACKER_PLUGIN_SDK_VERSION}
Expand All @@ -28,43 +30,16 @@ install-packer:
.PHONY: install-plugin
install-plugin: dev

.PHONY: clean
clean:
rm -f ${BINARY}

build:
@go build -o ${BINARY}

dev: build
@mkdir -p ~/.packer.d/plugins/
@mv ${BINARY} ~/.packer.d/plugins/${BINARY}
@mv ${BIN} ~/.packer.d/plugins/${BIN}

generate:
go generate ./...

.PHONY: test testacc
test:
go test $(TEST) $(TESTARGS) -v -timeout=30m -parallel=4 ;

testacc:
@echo "WARN: Acceptance tests will take a long time to run and may cost money. Ctrl-C if you want to cancel."
PACKER_ACC=1 go test -v $(TEST) $(TESTARGS) -timeout=45m

.PHONY: lint fmt golint goimports
lint: fmt goimports golangci-lint

fmt:
find . -name '*.go' | grep -v vendor | xargs gofmt -s -w

golangci-lint: fmt
golangci-lint run ./...

goimports:
find . -name '*.go' | grep -v vendor | xargs goimports -l -w

ci-release-docs: install-packer-sdc
@packer-sdc renderdocs -src docs -partials docs-partials/ -dst docs/
@/bin/sh -c "[ -d docs ] && zip -r docs.zip docs/"

plugin-check: install-packer-sdc build
@packer-sdc plugin-check ${BINARY}
@packer-sdc plugin-check ${BIN}
Loading