generated from cybozu-go/neco-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: zeroalphat <taichi-takemura@cybozu.co.jp>
- Loading branch information
1 parent
ab536a4
commit 441a77e
Showing
7 changed files
with
197 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
changelog: | ||
exclude: | ||
labels: | ||
- ignore-for-release | ||
- ci | ||
- documentation | ||
- refactoring | ||
- test | ||
categories: | ||
- title: Features | ||
labels: | ||
- enhancement | ||
- title: Bug Fixes | ||
labels: | ||
- bug | ||
- title: Deprecated | ||
labels: | ||
- deprecate | ||
- title: Removed | ||
labels: | ||
- remove | ||
- title: Security | ||
labels: | ||
- security | ||
- title: Dependencies | ||
labels: | ||
- dependencies | ||
- title: Others | ||
labels: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
jobs: | ||
image: | ||
name: Push Container Image | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: docker/setup-qemu-action@v3 | ||
with: | ||
platforms: linux/amd64 | ||
- uses: docker/setup-buildx-action@v3 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ inputs.github_token }} | ||
- name: Build necoperf-cli and necoperf-daemon image | ||
run: | | ||
make docker-build | ||
- name: Push necoperf-cli and necoperf-daemon image | ||
run: | | ||
IMAGE_TAG=${GITHUB_REF#refs/tags/v} # Remove "v" prefix. | ||
docker tag necoperf-cli:dev ghcr.io/cybozu-go/necoperf-cli:$IMAGE_TAG | ||
docker push ghcr.io/cybozu-go/necoperf-cli:$IMAGE_TAG | ||
docker tag necoperf-daemon:dev ghcr.io/cybozu-go/necoperf-daemon:$IMAGE_TAG | ||
docker push ghcr.io/cybozu-go/necoperf-daemon:$IMAGE_TAG | ||
release: | ||
name: Release on GitHub | ||
needs: image | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: 'go.mod' | ||
- name: GoReleaser | ||
uses: 'goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7' | ||
with: | ||
distribution: goreleaser | ||
version: v1.18.2 | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
builds: | ||
- id: necoperf-cli | ||
main: ./cmd/necoperf-cli | ||
binary: necoperf-cli | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
- id: necoperf-daemon | ||
main: ./cmd/necoperf-daemon | ||
binary: necoperf-daemon | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
|
||
archives: | ||
- id: necoperf-cli | ||
builds: [necoperf-cli] | ||
name_template: "necoperf-cli_{{ .Tag }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" | ||
wrap_in_directory: false | ||
format: tar.gz | ||
files: | ||
- LICENSE | ||
|
||
- id: necoperf-daemon | ||
builds: [necoperf-daemon] | ||
name_template: "necoperf-daemon_{{ .Tag }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" | ||
wrap_in_directory: false | ||
format: tar.gz | ||
files: | ||
- LICENSE | ||
|
||
checksum: | ||
name_template: "checksums.txt" | ||
|
||
changelog: | ||
use: github-native | ||
|
||
release: | ||
github: | ||
owner: zeroalphat | ||
name: necoperf-cli | ||
prerelease: auto | ||
name_template: "Release {{ .Tag }}" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM ghcr.io/cybozu/golang:1.21-jammy as builder | ||
|
||
COPY ./ . | ||
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o necoperf-cli ./cmd/necoperf-cli | ||
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o necoperf-daemon ./cmd/necoperf-daemon | ||
|
||
FROM ghcr.io/flatcar/flatcar-sdk-amd64:3654.0.0 as flatcar | ||
FROM k8s.gcr.io/pause:3.6 as pause | ||
|
||
FROM scratch | ||
COPY --from=flatcar /usr/bin/perf /usr/bin/sleep /usr/bin/ | ||
COPY --from=flatcar /bin/sh /bin/chown /bin/ | ||
COPY --from=flatcar /sbin/setcap /sbin/setcap | ||
|
||
COPY --from=flatcar /usr/lib64 /usr/lib64 | ||
COPY --from=flatcar /lib64 /lib64 | ||
COPY --from=flatcar /tmp /tmp | ||
|
||
COPY --from=pause /pause /usr/local/bin/pause | ||
COPY --from=builder /work/necoperf-cli /usr/local/bin/necoperf-cli | ||
COPY --from=builder /work/necoperf-daemon /usr/local/bin/necoperf-daemon | ||
|
||
RUN setcap "cap_perfmon,cap_sys_ptrace,cap_syslog,cap_sys_admin=ep" /usr/bin/perf \ | ||
&& chown -R 1000:1000 /tmp | ||
|
||
USER 1000:1000 | ||
ENTRYPOINT ["/usr/local/bin/necoperf-daemon", "daemon"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package e2e | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("necoperf e2e test", func() { | ||
It("should be able to run necoperf-cli", func() { | ||
By("executing necoperf-cli") | ||
_, err := kubectl(nil, "exec", "necoperf-client", "--", | ||
"necoperf-cli", "profile", "profiled-pod", | ||
"--timeout", "100s", | ||
"--necoperf-namespace", "necoperf") | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
By("checking if profiling result is created") | ||
_, err = kubectl(nil, "cp", "necoperf-client:/tmp/profiled-pod.script", "./profiled-pod.script") | ||
Expect(err).NotTo(HaveOccurred()) | ||
//Expect(string(out)).To(ContainSubstring("/tmp/profiled-pod.script")) | ||
}) | ||
}) |