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

feat: Initial implementation building images #1

Merged
merged 1 commit into from
Aug 26, 2023
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
5 changes: 5 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use asdf

PATH_add .local/bin

dotenv_if_exists .envrc.local
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
24 changes: 24 additions & 0 deletions .github/release.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

changelog:
exclude:
labels:
- ignore-for-release
- dependencies
authors:
- octocat
- dependabot
categories:
- title: Breaking Changes 🛠
labels:
- breaking
- title: Exciting New Features 🎉
labels:
- feature
- title: Fixes 🔧
labels:
- fix
- title: Other Changes
labels:
- "*"
105 changes: 105 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright 2023 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

name: checks

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- main

jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Install tools via asdf
uses: asdf-vm/actions/install@v2.1.0
with:
asdf_branch: v0.11.2

- name: Run unit tests
run: make test

- name: Annotate tests
if: always()
uses: guyarb/golang-test-annotations@v0.6.0
with:
test-results: test.json

lint:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Gather tool versions
uses: endorama/asdf-parse-tool-versions@v1
id: versions

- name: github-actions-lint
uses: reviewdog/action-actionlint@v1
with:
fail_on_error: true
reporter: github-pr-review

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
fail_on_error: true
reporter: github-pr-review
go_version: v${{ fromJson(steps.versions.outputs.tools).golang }}
golangci_lint_version: v${{ fromJson(steps.versions.outputs.tools).golangci-lint }}

pre-commit:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Gather tool versions
uses: endorama/asdf-parse-tool-versions@v1
id: versions

- uses: actions/setup-go@v4
with:
go-version: ${{ fromJson(steps.versions.outputs.tools).golang }}
check-latest: false
cache: true

- uses: mfinelli/setup-shfmt@v2
with:
shfmt-version: ${{ fromJson(steps.versions.outputs.tools).shfmt }}

- uses: pre-commit/action@v3.0.0
with:
extra_args: --all-files --show-diff-on-failure
env:
SKIP: no-commit-to-branch,golangci-lint

build-and-run:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Install tools via asdf
uses: asdf-vm/actions/install@v2.1.0
with:
asdf_branch: v0.11.2

- name: Build
run: make build-snapshot

- name: Run binary
run: |
./dist/kubernetes-upgrader_linux_amd64_v1/kubernetes-upgrader --version
43 changes: 43 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2023 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

name: codeql

on:
schedule:
- cron: '32 21 * * 2'
workflow_dispatch:

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Install tools via asdf
uses: asdf-vm/actions/install@v2.1.0
with:
asdf_branch: v0.11.2

- name: Build
run: make build-snapshot

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
14 changes: 14 additions & 0 deletions .github/workflows/conventional-label.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

name: conventional-release-labels
on:
pull_request_target:
types:
- opened
- edited
jobs:
label:
runs-on: ubuntu-latest
steps:
- uses: bcoe/conventional-release-labels@v1
16 changes: 16 additions & 0 deletions .github/workflows/conventional-pr-title.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

name: "conventional-pr-title"
on:
pull_request_target:
types:
- opened
- edited
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/dependabot-automation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2023 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

name: dependabot

on:
pull_request_target:
types:
- opened

permissions:
pull-requests: write
contents: write

jobs:
auto-approve:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v1
- uses: actions/checkout@v3
- name: Approve a PR if not already approved
run: |
gh pr checkout "$PR_URL" # sets the upstream metadata for `gh pr status`
if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ]; then
gh pr review --approve "$PR_URL"
else
echo "PR already approved, skipping additional approvals to minimize emails/notification noise."
fi
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

enable-automerge:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]'}}
steps:
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v1
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
35 changes: 35 additions & 0 deletions .github/workflows/release-please-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2023 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

name: release-please-main

on:
push:
branches:
- main

permissions:
contents: write
packages: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-22.04
# Map a step output to a job output
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}
steps:
- uses: google-github-actions/release-please-action@v3.7
id: release-please
with:
release-type: go
package-name: kubernetes-upgrader
pull-request-title-pattern: "build${scope}: release${component} ${version}"
changelog-notes-type: github

release-tag:
needs: release-please
uses: ./.github/workflows/release-tag.yaml
secrets: inherit
if: ${{ needs.release-please.outputs.release_created }}
31 changes: 31 additions & 0 deletions .github/workflows/release-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2023 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

name: release

on:
workflow_dispatch:
workflow_call:

permissions:
contents: write
packages: write

jobs:
release-tag:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Install tools via asdf
uses: asdf-vm/actions/install@v2.1.0
with:
asdf_branch: v0.11.2

- name: Release
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/stacked-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2023 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

name: stacked-prs

permissions:
actions: write
checks: write
issues: write
pull-requests: write
statuses: write

on:
pull_request_target:
types: [opened, edited, reopened, synchronize]

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: z0al/dependent-issues@v1
env:
# (Required) The token to use to make API calls to GitHub.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# (Optional) The label to use to mark dependent issues
label: stacked

# (Optional) A comma-separated list of keywords. Default
# "depends on, blocked by"
keywords: depends on, blocked by
Loading
Loading