Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
zizdlp committed Aug 11, 2024
0 parents commit dcfb6c5
Show file tree
Hide file tree
Showing 673 changed files with 103,294 additions and 0 deletions.
182 changes: 182 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
version: 2.1

commands: # a reusable command with parameters
task-docker:
parameters:
to:
default: "build"
type: string
steps:
- checkout
- setup_remote_docker
- run:
name: Install Docker
command: |
apt-get update
apt-get install curl -y
apt-get install apt-utils -y
curl -fsSL https://get.docker.com -o get-docker.sh
sh ./get-docker.sh
- run:
name: Install Docker Buildx
command: |
docker run --privileged --rm tonistiigi/binfmt --install all
mkdir -p ~/.docker/cli-plugins
docker buildx create --name mybuilder --use
docker buildx inspect --bootstrap
- run:
name: Switch to containerd image store
command: |
docker context create mycontext
docker context use mycontext
- run:
name: Login to Docker Hub
command: |
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
task-tag:
parameters:
to:
default: "build"
type: string
steps:
- run:
name: Check tag creator
command: |
authorized_users=("zizdlp")
if [[ ! " ${authorized_users[@]} " =~ " $CIRCLE_USERNAME " ]]; then
echo "Unauthorized user: $CIRCLE_USERNAME"
exit 1
fi
- run:
name: Ensure tag is greater than latest tag
command: |
current_tag=${CIRCLE_TAG}
git fetch --tags
latest_tag=$(git tag --sort=-v:refname --list 'v[0-9]*.[0-9]*.[0-9]*' | head -n1)
if [ -z "$latest_tag" ]; then
echo "No previous tags found. Assuming ${current_tag} is the first tag."
exit 0
fi
echo "Current tag: ${current_tag}"
echo "Latest tag: ${latest_tag}"
# Remove 'v' prefix and compare versions
current_version=$(echo "$current_tag" | sed 's/^v//')
latest_version=$(echo "$latest_tag" | sed 's/^v//')
# Compare versions
if [ "$(printf '%s\n%s\n' "$current_version" "$latest_version" | sort -V | head -n1)" != "$latest_version" ]; then
echo "Error: Tag ${current_tag} is not greater than or equal to the latest tag ${latest_tag}."
exit 1
fi
echo "Tag ${current_tag} is greater than or equal to the latest tag ${latest_tag}. Proceeding."
jobs:
build_frontend:
docker:
- image: ubuntu:22.04
steps:
- task-docker:
to: "build_frontend"
- task-tag:
to: "build_frontend"
- run:
name: Build multi-architecture zbook frontend image
command: |
docker buildx build --platform linux/amd64,linux/arm64 -t zizdlp/zbook_frontend:${CIRCLE_TAG} -t zizdlp/zbook_frontend:latest -f ./zbook_frontend/zbook_frontend.Dockerfile ./zbook_frontend --push
build_backend:
docker:
- image: ubuntu:22.04
steps:
- task-docker:
to: "build_frontend"
- task-tag:
to: "build_frontend"
- run:
name: Build multi-architecture zbook backend image
command: |
docker buildx build --platform linux/amd64,linux/arm64 -t zizdlp/zbook_backend:${CIRCLE_TAG} -t zizdlp/zbook_backend:latest -f ./zbook_backend/zbook_backend.Dockerfile ./zbook_backend --push
build_database:
docker:
- image: ubuntu:22.04
steps:
- task-docker:
to: "build_frontend"
- task-tag:
to: "build_frontend"
- run:
name: Build multi-architecture zbook database image
command: |
docker buildx build --platform linux/amd64,linux/arm64 -t zizdlp/zbook_database:${CIRCLE_TAG} -t zizdlp/zbook_database:latest -f ./zbook_database/zbook_database.Dockerfile ./zbook_database --push
build_release_frontend:
docker:
- image: ubuntu:22.04
steps:
- task-docker:
to: "build_another_frontend"
- run:
name: Build another multi-architecture frontend image
command: |
docker buildx build --platform linux/amd64,linux/arm64 -t zizdlp/zbook_frontend -f ./zbook_frontend/zbook_frontend.Dockerfile ./zbook_frontend
build_release_backend:
docker:
- image: ubuntu:22.04
steps:
- task-docker:
to: "build_another_backend"
- run:
name: Build another multi-architecture backend image
command: |
docker buildx build --platform linux/amd64,linux/arm64 -t zizdlp/zbook_backend -f ./zbook_backend/zbook_backend.Dockerfile ./zbook_backend
build_release_database:
docker:
- image: ubuntu:22.04
steps:
- task-docker:
to: "build_another_database"
- run:
name: Build another multi-architecture database image
command: |
docker buildx build --platform linux/amd64,linux/arm64 -t zizdlp/zbook_database -f ./zbook_database/zbook_database.Dockerfile ./zbook_database
workflows:
build-and-test:
jobs:
- build_frontend:
filters:
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
branches:
ignore: /.*/
- build_backend:
filters:
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
branches:
ignore: /.*/
- build_database:
filters:
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
branches:
ignore: /.*/
- build_release_frontend:
filters:
branches:
only: release
- build_release_backend:
filters:
branches:
only: release
- build_release_database:
filters:
branches:
only: release
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# .github/CODEOWNERS

* @zizdlp
31 changes: 31 additions & 0 deletions .github/workflows/build_main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: BUILD_MAIN

on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
service: [zbook_backend, zbook_database, zbook_frontend]
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.PRIVATE_REGISTRY_USERNAME }}
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
registry: ${{ secrets.PRIVATE_REGISTRY_URL }}
- name: Build and push ${{ matrix.service }}
uses: docker/build-push-action@v6
with:
context: "{{defaultContext}}:${{ matrix.service }}"
file: ${{ matrix.service }}.Dockerfile
platforms: linux/amd64
push: true
tags: ${{ secrets.PRIVATE_REGISTRY_URL }}/zbook/${{ matrix.service }}
42 changes: 42 additions & 0 deletions .github/workflows/test_backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: TEST_BACKEND

on:
push:
jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: zizdlp/zbook_database
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: secret
POSTGRES_DB: zbook
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.19
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Install golang-migrate
run: |
curl -L https://github.com/golang-migrate/migrate/releases/download/v4.14.1/migrate.linux-amd64.tar.gz | tar xvz
sudo mv migrate.linux-amd64 /usr/bin/migrate
which migrate
- name: Run migrations
run: make migrateup

- name: Test
run: make test
37 changes: 37 additions & 0 deletions .github/workflows/test_frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: TEST_FRONTEND

on:
push:
jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

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

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Change directory to frontend
run: cd zbook_frontend

- name: Install dependencies
run: npm install
working-directory: zbook_frontend
- name: Run lint
run: npm run lint
working-directory: zbook_frontend
- name: Run build
run: npm run build
working-directory: zbook_frontend

- name: Run tests
run: npm test -- --updateSnapshot
working-directory: zbook_frontend
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
zbook_data
__snapshots__
.swc
43 changes: 43 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"markdown-preview-enhanced.enablePreviewZenMode": false,
"protoc": {
"options": ["--proto_path=proto"]
},

"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

"[markdown]": {
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
},
"files.associations": {
".env*": "dotenv",
"vector": "cpp",
"iosfwd": "cpp"
},
"go.toolsManagement.autoUpdate": true,
"[proto3]": {
"editor.defaultFormatter": "zxh404.vscode-proto3"
},
"clang-format.style": "{ IndentWidth: 2, BasedOnStyle: google, AlignConsecutiveAssignments: AcrossEmptyLines, AlignAfterOpenBracket: AlwaysBreak}",
"editor.formatOnSave": true,
"[go]": {
"editor.defaultFormatter": "golang.go"
},
"i18n-ally.localesPaths": ["./zbook_frontend/messages"], // E.g. "./messages"
"i18n-ally.keystyle": "nested"
}
Loading

0 comments on commit dcfb6c5

Please sign in to comment.