Skip to content

Commit

Permalink
fix: push what I have
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpeterswa committed Apr 18, 2024
1 parent fe6ce72 commit bad233f
Show file tree
Hide file tree
Showing 15 changed files with 283 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

echo "running commitlint against git history"
npx -p @commitlint/config-conventional -p @commitlint/cli -c "cat $1 | commitlint"
10 changes: 10 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

echo "running yamllint against repository"
yamllint .

echo "running hadolint against Dockerfile"
hadolint Dockerfile

echo "running shellcheck against repository"
shellcheck scripts/**.sh -f gcc
77 changes: 77 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
on: [pull_request] # yamllint disable-line rule:truthy
name: main
jobs:

commitlint:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: lts/*
- run: npm install --save-dev @commitlint/{config-conventional,cli}
- run: npx commitlint --from=${{ github.event.pull_request.base.sha }}

golangci-lint:
strategy:
matrix:
go-version: [1.20.x]
os: [ubuntu-latest, macos-latest]
name: lint
runs-on: ${{ matrix.os }}
steps:

- uses: actions/checkout@v3

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.51.1

yamllint:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: yaml-lint
uses: ibiqlik/action-yamllint@v3

hadolint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: hadolint/[email protected]
with:
dockerfile: Dockerfile

test:
strategy:
matrix:
go-version: [1.20.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Test
run: go test ./...
29 changes: 29 additions & 0 deletions .github/workflows/push_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Release Version

on: # yamllint disable-line rule:truthy
push:
branches:
- main

jobs:
release:
name: 'Release to GitHub'
runs-on: ubuntu-latest
steps:

- name: Checkout repo
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*

- name: Install Semantic Release Plugins
run: npm install --save-dev @semantic-release/changelog @semantic-release/git conventional-changelog-conventionalcommits # yamllint disable-line rule:line-length

- name: Release Version
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT }}
run: npx semantic-release
47 changes: 47 additions & 0 deletions .github/workflows/upload_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Upload Image

on: # yamllint disable-line rule:truthy
release:
types:
- created

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

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

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
10 changes: 10 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
branches:
- master
- main
plugins:
- - "@semantic-release/commit-analyzer"
- preset: conventionalcommits
- - "@semantic-release/release-notes-generator"
- preset: conventionalcommits
- - "@semantic-release/github"
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# archlinux is rolling release, not specifying version
# hadolint ignore=DL3006
FROM --platform=$BUILDPLATFORM archlinux as stage1

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

COPY scripts/ /scripts/
RUN /scripts/configure.sh

FROM stage1 as stage2
RUN /scripts/install_packages.sh

FROM stage2 as stage3
RUN /scripts/modify_shell.sh
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Makefile
all: setup hooks

# requires `nvm use --lts` or `nvm use node`
.PHONY: setup
setup:
npm install -g @commitlint/config-conventional @commitlint/cli
brew install hadolint
brew install shellcheck


.PHONY: hooks
hooks:
@git config --local core.hooksPath .githooks/
6 changes: 6 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
ignores: [
(message) => message.includes('Initial commit')
],
};
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: "3.3"

services:
konnect:
build: .
command: sleep infinity
8 changes: 8 additions & 0 deletions scripts/aurlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
zsh
inetutils
redis
mariadb
clickhouse
mongosh-bin
google-cloud-cli
croc
7 changes: 7 additions & 0 deletions scripts/configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Address Security Concerns
pacman-key --init

# Update All Packages
pacman -Syu --noconfirm
37 changes: 37 additions & 0 deletions scripts/install_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Install packages from pkglist.txt
pacman -S --needed --noconfirm - < scripts/pkglist.txt

# Yay temporary build directory and user creation
mkdir -p /tmp/yay-build
useradd -m -G wheel builder && passwd -d builder
chown -R builder:builder /tmp/yay-build
echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

# Install yay
su - builder -c "git clone https://aur.archlinux.org/yay.git /tmp/yay-build/yay"
su - builder -c "cd /tmp/yay-build/yay && makepkg -si --noconfirm"

# Remove yay temporary build directory
# rm -rf /tmp/yay-build

# Add non-root user captain
# useradd -m -G wheel captain && passwd -d captain

# Install packages from aurlist.txt
yay -S --noconfirm - < /scripts/aurlist.txt

# Install evans
unamestr=$(uname -m)
if [ "$unamestr" = "x86_64" ]; then
curl -sSLO https://github.com/ktr0731/evans/releases/download/v0.10.11/evans_linux_amd64.tar.gz
tar -xvzf evans_linux_amd64.tar.gz
mv evans /usr/local/bin
rm -rf evans_linux_amd64.tar.gz
elif [ "$unamestr" = "aarch64" ] || [ $unamestr = "arm64" ]; then
curl -sSLO https://github.com/ktr0731/evans/releases/download/v0.10.11/evans_linux_arm64.tar.gz
tar -xvzf evans_linux_arm64.tar.gz
mv evans /usr/local/bin
rm -rf evans_linux_arm64.tar.gz
fi
7 changes: 7 additions & 0 deletions scripts/modify_shell.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Change default shell to zsh
chsh -s /bin/zsh

# Install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
6 changes: 6 additions & 0 deletions scripts/pkglist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
base
base-devel
git
sudo
go
coreutils

0 comments on commit bad233f

Please sign in to comment.