mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-12-20 03:41:16 +00:00
CI: Concatenate workflow into one workflow
from one file per job through script Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
264eef4130
commit
6c941fb330
19 changed files with 798 additions and 423 deletions
57
.github/workflows/doc-generator.yml
vendored
57
.github/workflows/doc-generator.yml
vendored
|
@ -1,57 +0,0 @@
|
|||
---
|
||||
|
||||
name: doc-generator
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
doc-generator:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
curl \
|
||||
git \
|
||||
git-lfs \
|
||||
make \
|
||||
tar
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
lfs: true
|
||||
submodules: true
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Generate documentation
|
||||
run: make render_docs DOCS_BASE_URL=https://luzifer.github.io/twitch-bot/
|
||||
|
||||
- name: Upload GitHub Pages artifact
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-pages-artifact@v1
|
||||
with:
|
||||
path: .rendered-docs
|
||||
|
||||
- name: Deploy artifact
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: actions/deploy-pages@v1
|
||||
|
||||
...
|
36
.github/workflows/docker-publish.yml
vendored
36
.github/workflows/docker-publish.yml
vendored
|
@ -1,36 +0,0 @@
|
|||
---
|
||||
|
||||
name: docker-publish
|
||||
on:
|
||||
push:
|
||||
branches: ['master']
|
||||
tags: ['v*']
|
||||
|
||||
permissions:
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
docker-publish:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
show-progress: false
|
||||
|
||||
- name: Log into registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Docker Build & Publish
|
||||
run: bash ci/docker-publish.sh
|
||||
|
||||
...
|
341
.github/workflows/generated_workflow.yml
vendored
Normal file
341
.github/workflows/generated_workflow.yml
vendored
Normal file
|
@ -0,0 +1,341 @@
|
|||
name: CI Workflow
|
||||
on: push
|
||||
permissions:
|
||||
packages: write
|
||||
jobs:
|
||||
doc-generator:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||
needs:
|
||||
- test
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
curl \
|
||||
git \
|
||||
git-lfs \
|
||||
make \
|
||||
tar
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
show-progress: false
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
- name: Generate documentation
|
||||
run: make render_docs DOCS_BASE_URL=https://luzifer.github.io/twitch-bot/
|
||||
- name: Upload GitHub Pages artifact
|
||||
uses: actions/upload-pages-artifact@v1
|
||||
with:
|
||||
path: .rendered-docs
|
||||
- name: Deploy artifact
|
||||
uses: actions/deploy-pages@v1
|
||||
docker-publish:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master' }}
|
||||
needs:
|
||||
- test
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
show-progress: false
|
||||
- name: Log into registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Docker Build & Publish
|
||||
run: bash ci/docker-publish.sh
|
||||
integration-crdb:
|
||||
if: ${{ github.ref == 'refs/heads/master' }}
|
||||
needs:
|
||||
- test
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
crdb:
|
||||
image: luzifer/crdb-gh-service
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
cockroachdb-bin \
|
||||
git \
|
||||
go \
|
||||
make
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
- name: Set up CRDB service
|
||||
run: |
|
||||
cockroach sql --host crdb --insecure <<EOF
|
||||
CREATE DATABASE integration;
|
||||
CREATE USER "twitch_bot" WITH PASSWORD NULL;
|
||||
ALTER DATABASE integration OWNER to "twitch_bot";
|
||||
EOF
|
||||
- name: Run tests against CRDB
|
||||
env:
|
||||
GO_TEST_DB_ENGINE: postgres
|
||||
GO_TEST_DB_DSN: host=crdb user=twitch_bot dbname=integration port=26257 sslmode=disable timezone=UTC
|
||||
run: make short_test
|
||||
integration-mariadb:
|
||||
if: ${{ github.ref == 'refs/heads/master' }}
|
||||
needs:
|
||||
- test
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:11
|
||||
env:
|
||||
MYSQL_PASSWORD: twitch-bot-pass
|
||||
MYSQL_ROOT_PASSWORD: root-pass
|
||||
MYSQL_USER: twitch-bot
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
git \
|
||||
go \
|
||||
make \
|
||||
mariadb-clients
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
- name: Set up MariaDB service
|
||||
run: |
|
||||
mariadb -h mariadb -u root --password=root-pass <<EOF
|
||||
CREATE DATABASE integration DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
||||
GRANT ALL ON integration.* TO 'twitch-bot'@'%';
|
||||
EOF
|
||||
- name: Run tests against MariaDB
|
||||
env:
|
||||
GO_TEST_DB_ENGINE: mysql
|
||||
GO_TEST_DB_DSN: twitch-bot:twitch-bot-pass@tcp(mariadb:3306)/integration?charset=utf8mb4&parseTime=True
|
||||
run: make short_test
|
||||
integration-mysql:
|
||||
if: ${{ github.ref == 'refs/heads/master' }}
|
||||
needs:
|
||||
- test
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8
|
||||
env:
|
||||
MYSQL_PASSWORD: twitch-bot-pass
|
||||
MYSQL_ROOT_PASSWORD: root-pass
|
||||
MYSQL_USER: twitch-bot
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
git \
|
||||
go \
|
||||
make \
|
||||
mariadb-clients
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
- name: Set up MySQL service
|
||||
run: |
|
||||
mariadb -h mysql -u root --password=root-pass <<EOF
|
||||
CREATE DATABASE integration DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
||||
GRANT ALL ON integration.* TO 'twitch-bot'@'%';
|
||||
EOF
|
||||
- name: Run tests against MySQL
|
||||
env:
|
||||
GO_TEST_DB_ENGINE: mysql
|
||||
GO_TEST_DB_DSN: twitch-bot:twitch-bot-pass@tcp(mysql:3306)/integration?charset=utf8mb4&parseTime=True
|
||||
run: make short_test
|
||||
integration-postgres:
|
||||
if: ${{ github.ref == 'refs/heads/master' }}
|
||||
needs:
|
||||
- test
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
env:
|
||||
POSTGRES_PASSWORD: twitch-bot-pass
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
git \
|
||||
go \
|
||||
make
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
- name: Run tests against PostgreSQL
|
||||
env:
|
||||
GO_TEST_DB_ENGINE: postgres
|
||||
GO_TEST_DB_DSN: host=postgres user=postgres password=twitch-bot-pass dbname=postgres port=5432 sslmode=disable timezone=UTC
|
||||
run: make short_test
|
||||
release:
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||
needs:
|
||||
- test
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
awk \
|
||||
curl \
|
||||
diffutils \
|
||||
git \
|
||||
git-lfs \
|
||||
go \
|
||||
golangci-lint-bin \
|
||||
make \
|
||||
nodejs-lts-hydrogen \
|
||||
npm \
|
||||
tar \
|
||||
trivy \
|
||||
unzip \
|
||||
which \
|
||||
zip
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
show-progress: false
|
||||
- name: Marking workdir safe
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
- name: Build release
|
||||
run: make publish
|
||||
- name: Extract changelog
|
||||
run: awk "/^#/ && ++c==2{exit}; /^#/f" "History.md" | tail -n +2 >release_changelog.md
|
||||
- name: Update stable branch
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
git branch -f stable ${GITHUB_SHA}
|
||||
git push -f origin stable
|
||||
- name: Release
|
||||
uses: ncipollo/release-action@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
artifacts: .build/*
|
||||
bodyFile: release_changelog.md
|
||||
draft: false
|
||||
generateReleaseNotes: false
|
||||
test:
|
||||
if: ${{ github.ref != 'refs/heads/stable' }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
awk \
|
||||
curl \
|
||||
diffutils \
|
||||
git \
|
||||
git-lfs \
|
||||
go \
|
||||
golangci-lint-bin \
|
||||
make \
|
||||
nodejs-lts-hydrogen \
|
||||
npm \
|
||||
tar \
|
||||
trivy \
|
||||
unzip \
|
||||
which \
|
||||
zip
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
show-progress: false
|
||||
- name: Marking workdir safe
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
- name: Lint and test code
|
||||
run: make lint test frontend_lint
|
||||
- name: Build release (quick local for compile)
|
||||
run: make build_prod
|
||||
- name: Execute Trivy scan
|
||||
run: make trivy
|
61
.github/workflows/integration-crdb.yml
vendored
61
.github/workflows/integration-crdb.yml
vendored
|
@ -1,61 +0,0 @@
|
|||
---
|
||||
|
||||
name: integration-crdb
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
test:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
crdb:
|
||||
image: luzifer/crdb-gh-service
|
||||
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
cockroachdb-bin \
|
||||
git \
|
||||
go \
|
||||
make
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Set up CRDB service
|
||||
run: |
|
||||
cockroach sql --host crdb --insecure <<EOF
|
||||
CREATE DATABASE integration;
|
||||
CREATE USER "twitch_bot" WITH PASSWORD NULL;
|
||||
ALTER DATABASE integration OWNER to "twitch_bot";
|
||||
EOF
|
||||
|
||||
- name: Run tests against CRDB
|
||||
env:
|
||||
GO_TEST_DB_ENGINE: postgres
|
||||
GO_TEST_DB_DSN: host=crdb user=twitch_bot dbname=integration port=26257 sslmode=disable timezone=UTC
|
||||
run: make test
|
||||
|
||||
...
|
64
.github/workflows/integration-mariadb.yml
vendored
64
.github/workflows/integration-mariadb.yml
vendored
|
@ -1,64 +0,0 @@
|
|||
---
|
||||
|
||||
name: integration-mariadb
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
test:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:11
|
||||
env:
|
||||
MYSQL_PASSWORD: twitch-bot-pass
|
||||
MYSQL_ROOT_PASSWORD: root-pass
|
||||
MYSQL_USER: twitch-bot
|
||||
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
git \
|
||||
go \
|
||||
make \
|
||||
mariadb-clients
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Set up MariaDB service
|
||||
run: |
|
||||
mariadb -h mariadb -u root --password=root-pass <<EOF
|
||||
CREATE DATABASE integration DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
||||
GRANT ALL ON integration.* TO 'twitch-bot'@'%';
|
||||
EOF
|
||||
|
||||
- name: Run tests against MariaDB
|
||||
env:
|
||||
GO_TEST_DB_ENGINE: mysql
|
||||
GO_TEST_DB_DSN: twitch-bot:twitch-bot-pass@tcp(mariadb:3306)/integration?charset=utf8mb4&parseTime=True
|
||||
run: make test
|
||||
|
||||
...
|
64
.github/workflows/integration-mysql.yml
vendored
64
.github/workflows/integration-mysql.yml
vendored
|
@ -1,64 +0,0 @@
|
|||
---
|
||||
|
||||
name: integration-mysql
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
test:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8
|
||||
env:
|
||||
MYSQL_PASSWORD: twitch-bot-pass
|
||||
MYSQL_ROOT_PASSWORD: root-pass
|
||||
MYSQL_USER: twitch-bot
|
||||
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
git \
|
||||
go \
|
||||
make \
|
||||
mariadb-clients
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Set up MySQL service
|
||||
run: |
|
||||
mariadb -h mysql -u root --password=root-pass <<EOF
|
||||
CREATE DATABASE integration DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
||||
GRANT ALL ON integration.* TO 'twitch-bot'@'%';
|
||||
EOF
|
||||
|
||||
- name: Run tests against MySQL
|
||||
env:
|
||||
GO_TEST_DB_ENGINE: mysql
|
||||
GO_TEST_DB_DSN: twitch-bot:twitch-bot-pass@tcp(mysql:3306)/integration?charset=utf8mb4&parseTime=True
|
||||
run: make test
|
||||
|
||||
...
|
54
.github/workflows/integration-postgres.yml
vendored
54
.github/workflows/integration-postgres.yml
vendored
|
@ -1,54 +0,0 @@
|
|||
---
|
||||
|
||||
name: integration-postgres
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
test:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
env:
|
||||
POSTGRES_PASSWORD: twitch-bot-pass
|
||||
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
git \
|
||||
go \
|
||||
make
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Run tests against PostgreSQL
|
||||
env:
|
||||
GO_TEST_DB_ENGINE: postgres
|
||||
GO_TEST_DB_DSN: host=postgres user=postgres password=twitch-bot-pass dbname=postgres port=5432 sslmode=disable timezone=UTC
|
||||
run: make test
|
||||
|
||||
...
|
87
.github/workflows/test-and-build.yml
vendored
87
.github/workflows/test-and-build.yml
vendored
|
@ -1,87 +0,0 @@
|
|||
---
|
||||
|
||||
name: test-and-build
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- stable
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
test-and-build:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
awk \
|
||||
curl \
|
||||
diffutils \
|
||||
git \
|
||||
git-lfs \
|
||||
go \
|
||||
golangci-lint-bin \
|
||||
make \
|
||||
nodejs-lts-hydrogen \
|
||||
npm \
|
||||
tar \
|
||||
trivy \
|
||||
unzip \
|
||||
which \
|
||||
zip
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
show-progress: false
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Lint and test code
|
||||
run: make lint test frontend_lint
|
||||
|
||||
- name: Build release
|
||||
run: make publish
|
||||
|
||||
- name: Execute Trivy scan
|
||||
run: make trivy
|
||||
|
||||
- name: Extract changelog
|
||||
run: 'awk "/^#/ && ++c==2{exit}; /^#/f" "History.md" | tail -n +2 >release_changelog.md'
|
||||
|
||||
- name: Update stable branch
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
git branch -f stable ${GITHUB_SHA}
|
||||
git push -f origin stable
|
||||
|
||||
- name: Release
|
||||
uses: ncipollo/release-action@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
artifacts: '.build/*'
|
||||
bodyFile: release_changelog.md
|
||||
draft: false
|
||||
generateReleaseNotes: false
|
||||
|
||||
...
|
6
Makefile
6
Makefile
|
@ -15,6 +15,9 @@ lint:
|
|||
publish: frontend_prod
|
||||
bash ./ci/build.sh
|
||||
|
||||
short_test:
|
||||
go test -cover -test.short -v ./...
|
||||
|
||||
test:
|
||||
go test -cover -v ./...
|
||||
|
||||
|
@ -41,6 +44,9 @@ update_ua_list:
|
|||
# User-Agents provided by https://www.useragents.me/
|
||||
curl -sSf https://www.useragents.me/api | jq -r '.data[].ua' | grep -v 'Trident' >internal/linkcheck/user-agents.txt
|
||||
|
||||
gh-workflow:
|
||||
bash ci/create-workflow.sh
|
||||
|
||||
# -- Vulnerability scanning --
|
||||
|
||||
trivy:
|
||||
|
|
15
ci/create-workflow.sh
Normal file
15
ci/create-workflow.sh
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
target_file=.github/workflows/generated_workflow.yml
|
||||
source_files=($(find ci/workflow-parts -name 'part_*'))
|
||||
base=ci/workflow-parts/index.yaml
|
||||
|
||||
cp ${base} ${target_file}
|
||||
|
||||
for source_file in "${source_files[@]}"; do
|
||||
job_name=${source_file##*/part_}
|
||||
job_name=${job_name%%.*}
|
||||
yq -P ".jobs.${job_name} |= load(\"${source_file}\")" ${target_file} >${target_file}.new
|
||||
mv ${target_file}.new ${target_file}
|
||||
done
|
7
ci/workflow-parts/index.yaml
Normal file
7
ci/workflow-parts/index.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
name: CI Workflow
|
||||
on: push
|
||||
|
||||
permissions:
|
||||
packages: write
|
||||
|
||||
jobs: {}
|
53
ci/workflow-parts/part_doc-generator.yml
Normal file
53
ci/workflow-parts/part_doc-generator.yml
Normal file
|
@ -0,0 +1,53 @@
|
|||
---
|
||||
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||
needs: [test]
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
curl \
|
||||
git \
|
||||
git-lfs \
|
||||
make \
|
||||
tar
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
show-progress: false
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Generate documentation
|
||||
run: make render_docs DOCS_BASE_URL=https://luzifer.github.io/twitch-bot/
|
||||
|
||||
- name: Upload GitHub Pages artifact
|
||||
uses: actions/upload-pages-artifact@v1
|
||||
with:
|
||||
path: .rendered-docs
|
||||
|
||||
- name: Deploy artifact
|
||||
uses: actions/deploy-pages@v1
|
||||
|
||||
...
|
28
ci/workflow-parts/part_docker-publish.yml
Normal file
28
ci/workflow-parts/part_docker-publish.yml
Normal file
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master' }}
|
||||
needs: [test]
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
show-progress: false
|
||||
|
||||
- name: Log into registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Docker Build & Publish
|
||||
run: bash ci/docker-publish.sh
|
||||
|
||||
...
|
55
ci/workflow-parts/part_integration-crdb.yml
Normal file
55
ci/workflow-parts/part_integration-crdb.yml
Normal file
|
@ -0,0 +1,55 @@
|
|||
---
|
||||
|
||||
if: ${{ github.ref == 'refs/heads/master' }}
|
||||
needs: [test]
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
crdb:
|
||||
image: luzifer/crdb-gh-service
|
||||
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
cockroachdb-bin \
|
||||
git \
|
||||
go \
|
||||
make
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Set up CRDB service
|
||||
run: |
|
||||
cockroach sql --host crdb --insecure <<EOF
|
||||
CREATE DATABASE integration;
|
||||
CREATE USER "twitch_bot" WITH PASSWORD NULL;
|
||||
ALTER DATABASE integration OWNER to "twitch_bot";
|
||||
EOF
|
||||
|
||||
- name: Run tests against CRDB
|
||||
env:
|
||||
GO_TEST_DB_ENGINE: postgres
|
||||
GO_TEST_DB_DSN: host=crdb user=twitch_bot dbname=integration port=26257 sslmode=disable timezone=UTC
|
||||
run: make short_test
|
||||
|
||||
...
|
58
ci/workflow-parts/part_integration-mariadb.yml
Normal file
58
ci/workflow-parts/part_integration-mariadb.yml
Normal file
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
|
||||
if: ${{ github.ref == 'refs/heads/master' }}
|
||||
needs: [test]
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:11
|
||||
env:
|
||||
MYSQL_PASSWORD: twitch-bot-pass
|
||||
MYSQL_ROOT_PASSWORD: root-pass
|
||||
MYSQL_USER: twitch-bot
|
||||
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
git \
|
||||
go \
|
||||
make \
|
||||
mariadb-clients
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Set up MariaDB service
|
||||
run: |
|
||||
mariadb -h mariadb -u root --password=root-pass <<EOF
|
||||
CREATE DATABASE integration DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
||||
GRANT ALL ON integration.* TO 'twitch-bot'@'%';
|
||||
EOF
|
||||
|
||||
- name: Run tests against MariaDB
|
||||
env:
|
||||
GO_TEST_DB_ENGINE: mysql
|
||||
GO_TEST_DB_DSN: twitch-bot:twitch-bot-pass@tcp(mariadb:3306)/integration?charset=utf8mb4&parseTime=True
|
||||
run: make short_test
|
||||
|
||||
...
|
58
ci/workflow-parts/part_integration-mysql.yml
Normal file
58
ci/workflow-parts/part_integration-mysql.yml
Normal file
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
|
||||
if: ${{ github.ref == 'refs/heads/master' }}
|
||||
needs: [test]
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8
|
||||
env:
|
||||
MYSQL_PASSWORD: twitch-bot-pass
|
||||
MYSQL_ROOT_PASSWORD: root-pass
|
||||
MYSQL_USER: twitch-bot
|
||||
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
git \
|
||||
go \
|
||||
make \
|
||||
mariadb-clients
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Set up MySQL service
|
||||
run: |
|
||||
mariadb -h mysql -u root --password=root-pass <<EOF
|
||||
CREATE DATABASE integration DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
|
||||
GRANT ALL ON integration.* TO 'twitch-bot'@'%';
|
||||
EOF
|
||||
|
||||
- name: Run tests against MySQL
|
||||
env:
|
||||
GO_TEST_DB_ENGINE: mysql
|
||||
GO_TEST_DB_DSN: twitch-bot:twitch-bot-pass@tcp(mysql:3306)/integration?charset=utf8mb4&parseTime=True
|
||||
run: make short_test
|
||||
|
||||
...
|
48
ci/workflow-parts/part_integration-postgres.yml
Normal file
48
ci/workflow-parts/part_integration-postgres.yml
Normal file
|
@ -0,0 +1,48 @@
|
|||
---
|
||||
|
||||
if: ${{ github.ref == 'refs/heads/master' }}
|
||||
needs: [test]
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
env:
|
||||
POSTGRES_PASSWORD: twitch-bot-pass
|
||||
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
git \
|
||||
go \
|
||||
make
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
show-progress: false
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Run tests against PostgreSQL
|
||||
env:
|
||||
GO_TEST_DB_ENGINE: postgres
|
||||
GO_TEST_DB_DSN: host=postgres user=postgres password=twitch-bot-pass dbname=postgres port=5432 sslmode=disable timezone=UTC
|
||||
run: make short_test
|
||||
|
||||
...
|
71
ci/workflow-parts/part_release.yml
Normal file
71
ci/workflow-parts/part_release.yml
Normal file
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
|
||||
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||
needs: [test]
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
awk \
|
||||
curl \
|
||||
diffutils \
|
||||
git \
|
||||
git-lfs \
|
||||
go \
|
||||
golangci-lint-bin \
|
||||
make \
|
||||
nodejs-lts-hydrogen \
|
||||
npm \
|
||||
tar \
|
||||
trivy \
|
||||
unzip \
|
||||
which \
|
||||
zip
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
show-progress: false
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Build release
|
||||
run: make publish
|
||||
|
||||
- name: Extract changelog
|
||||
run: 'awk "/^#/ && ++c==2{exit}; /^#/f" "History.md" | tail -n +2 >release_changelog.md'
|
||||
|
||||
- name: Update stable branch
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
git branch -f stable ${GITHUB_SHA}
|
||||
git push -f origin stable
|
||||
|
||||
- name: Release
|
||||
uses: ncipollo/release-action@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
artifacts: '.build/*'
|
||||
bodyFile: release_changelog.md
|
||||
draft: false
|
||||
generateReleaseNotes: false
|
||||
|
||||
...
|
58
ci/workflow-parts/part_test.yml
Normal file
58
ci/workflow-parts/part_test.yml
Normal file
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
|
||||
if: ${{ github.ref != 'refs/heads/stable' }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: luzifer/archlinux
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
GOPATH: /go
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Enable custom AUR package repo
|
||||
run: echo -e "[luzifer]\nSigLevel = Never\nServer = https://archrepo.hub.luzifer.io/\$arch" >>/etc/pacman.conf
|
||||
|
||||
- name: Install required packages
|
||||
run: |
|
||||
pacman -Syy --noconfirm \
|
||||
awk \
|
||||
curl \
|
||||
diffutils \
|
||||
git \
|
||||
git-lfs \
|
||||
go \
|
||||
golangci-lint-bin \
|
||||
make \
|
||||
nodejs-lts-hydrogen \
|
||||
npm \
|
||||
tar \
|
||||
trivy \
|
||||
unzip \
|
||||
which \
|
||||
zip
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
show-progress: false
|
||||
|
||||
- name: Marking workdir safe
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||
|
||||
- name: Lint and test code
|
||||
run: make lint test frontend_lint
|
||||
|
||||
- name: Build release (quick local for compile)
|
||||
run: make build_prod
|
||||
|
||||
- name: Execute Trivy scan
|
||||
run: make trivy
|
||||
|
||||
...
|
Loading…
Reference in a new issue