Skip to content

Commit

Permalink
refactor: improve setup and maintainability (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
cugu authored Jul 7, 2024
1 parent f5fcee0 commit 619c5c6
Show file tree
Hide file tree
Showing 553 changed files with 11,267 additions and 91,666 deletions.
119 changes: 11 additions & 108 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,127 +4,30 @@ on:
pull_request:
release: { types: [ published ] }

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

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with: { go-version: '1.21' }
- run: |
mkdir -p ui/dist/img
touch ui/dist/index.html ui/dist/favicon.ico ui/dist/manifest.json ui/dist/img/fake.png
- uses: golangci/golangci-lint-action@v3
with: { version: 'v1.54' }
with: { go-version: '1.22' }
- uses: oven-sh/setup-bun@v1

- run: make build-ui

- uses: golangci/golangci-lint-action@v6
with: { version: 'v1.59' }

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '14', cache: 'yarn', cache-dependency-path: 'ui/yarn.lock' }
- uses: actions/setup-go@v4
with: { go-version: '1.21' }
- run: |
mkdir -p ui/dist/img
touch ui/dist/index.html ui/dist/favicon.ico ui/dist/manifest.json ui/dist/img/fake.png
- run: docker compose up --quiet-pull --detach
working-directory: dev
- run: go test -coverprofile=cover.out -coverpkg=./... ./...
- run: go tool cover -func=cover.out
- uses: codecov/codecov-action@v3

cypress:
strategy:
matrix:
test: [ tickets, templates, playbooks ]
auth: [ authelia ]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with: { go-version: '1.21' }
- uses: actions/setup-node@v4
with: { node-version: '14' }
# run UI
- run: |
yarn install
yarn serve &
working-directory: ui
- run: curl --head -X GET --retry 60 --retry-all-errors --retry-delay 10 http://localhost:8080
# run containers
- run: sed -i 's/host.docker.internal/172.17.0.1/g' dev/nginx.conf
- run: docker compose up --quiet-pull --detach
working-directory: dev
if: matrix.auth == 'authelia'
- run: curl --head -X GET --retry 60 --retry-all-errors --retry-delay 10 http://localhost:8082
if: matrix.auth == 'authelia'
# run catalyst
- run: |
mkdir -p ui/dist/img
touch ui/dist/index.html ui/dist/favicon.ico ui/dist/manifest.json ui/dist/img/fake.png
- run: go mod download
- run: bash start_dev.sh &
working-directory: dev
if: matrix.auth == 'authelia'
- run: curl --head -X GET --retry 60 --retry-all-errors --retry-delay 10 http://localhost:8000
# run cypress
- uses: cypress-io/github-action@v4
env:
CYPRESS_AUTH: ${{ matrix.auth }}
CYPRESS_TEST: ${{ matrix.test }}
with:
browser: chrome
working-directory: ui
with: { go-version: '1.22' }
- uses: oven-sh/setup-bun@v1

build-npm:
name: Build npm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '14', cache: 'yarn', cache-dependency-path: 'ui/yarn.lock' }
- run: yarn install && yarn build
working-directory: ui
- uses: actions/upload-artifact@v3
with: { name: ui, path: ui/dist, retention-days: 1 }
- run: make build-ui

build:
if: github.event_name != 'pull_request'
name: Build
runs-on: ubuntu-latest
needs: [ build-npm, test ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with: { go-version: '1.21' }
- uses: actions/download-artifact@v3
with: { name: ui, path: ui/dist }
- name: Version
if: github.ref_type == 'tag' && github.ref_name != ''
run: |
echo ${{ github.ref_name }}
echo ${{ github.ref_name }} > VERSION
- run: go build -o catalyst ./cmd/catalyst/.
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- run: make test
32 changes: 32 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: goreleaser

on:
pull_request:
push:
tags:
- "*"

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v5
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107 changes: 28 additions & 79 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,87 +1,36 @@
.idea
.antlr
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
uploads
gen

*.bleve

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
dist-ssr
coverage
*.local

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
/cypress/videos/
/cypress/screenshots/

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
venv/
.venv/
.python-version
.pytest_cache

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

#Ipython Notebook
.ipynb_checkpoints
*.tsbuildinfo

# npm
wwwroot/*.js
typings
bin
dist
node_modules

profile.cov
cover.out

generated/caql/parser/*.interp
generated/caql/parser/*.tokens
pb_data
catalyst
catalyst_data
Loading

0 comments on commit 619c5c6

Please sign in to comment.