Skip to content

Commit

Permalink
Merge pull request #345 from ArtalkJS/refactor/bump-to-monorepo
Browse files Browse the repository at this point in the history
fefactor: bump to monorepo
  • Loading branch information
qwqcode authored Jan 19, 2023
2 parents afe196d + 1ca892f commit d52b2f5
Show file tree
Hide file tree
Showing 432 changed files with 20,940 additions and 140 deletions.
105 changes: 105 additions & 0 deletions .circleci/conditional_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
version: 2.1

orbs:
node: circleci/[email protected]

executors:
base:
docker:
- image: cimg/base:stable
node:
docker:
- image: 'cimg/node:16.15.1'
go:
docker:
- image: cimg/go:1.19

parameters:
trigger-app:
type: boolean
default: false
trigger-ui:
type: boolean
default: false
run-them-all:
type: boolean
default: false

jobs:
## Backend
test_app:
executor: go
working_directory: ~/go/src/github.com/ArtalkJS/Artalk
environment:
GO111MODULE: "on"
steps:
- checkout
- run:
name: "Print the Go version"
command: >
go version
- restore_cache:
keys:
- go-mod-1.19-{{ checksum "go.sum" }}
- run:
name: Install Dependencies
command: go mod download
- save_cache:
key: go-mod-1.19-{{ checksum "go.sum" }}
paths:
- "~/go/pkg/mod"
- run:
name: Run tests
command: |
mkdir -p /tmp/test-reports
gotestsum --junitfile /tmp/test-reports/unit-tests.xml
- store_test_results:
path: /tmp/test-reports

## Frontend
test_ui:
executor: node
steps:
- node/install
- checkout
- run:
name: Print the node version
command: node -v
- run:
name: Install pnpm
command: npm i -g [email protected]
- run:
name: Install Dependencies
command: pnpm --dir ./ui install --frozen-lockfile
- run:
name: Build Artalk
command: pnpm --dir ./ui build:all

all_projects:
executor: base
steps:
- run:
command: |
echo "all"
workflows:
build-app:
when:
or:
- << pipeline.parameters.trigger-app >>
- << pipeline.parameters.run-them-all >>
jobs:
- test_app

build-ui:
when:
or:
- << pipeline.parameters.trigger-ui >>
- << pipeline.parameters.run-them-all >>
jobs:
- test_ui

build-shared-other:
when: << pipeline.parameters.run-them-all >>
jobs:
- all_projects
39 changes: 17 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
# https://circleci.com/docs/2.0/configuration-reference
version: 2.1

# this allows you to use CircleCI's dynamic configuration
# https://circleci.com/docs/2.0/dynamic-config/
setup: true

# the path-filtering orb is required to continue a pipeline based on
# https://circleci.com/developer/orbs/orb/circleci/path-filtering
orbs:
node: circleci/[email protected]
jobs:
build:
docker:
- image: 'cimg/node:16.15.1'
steps:
- node/install
- checkout
- run:
name: Print the node version
command: node -v
- run:
name: Install pnpm
command: npm i -g [email protected]
- run:
name: Install Dependencies
command: pnpm install --frozen-lockfile
- run:
name: Build Artalk
command: pnpm build:all
path-filtering: circleci/[email protected]

workflows:
tests:
setup:
jobs:
- build:
- path-filtering/filter:
mapping: |
(cmd|internal|server|pkg|test)/.* trigger-app true
main.go|go.mod|go.sum|artalk.example.yml trigger-app true
(ui)/.* trigger-ui true
base-revision: master # git branch name
config-path: .circleci/conditional_config.yml
filters:
branches:
ignore:
Expand Down
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@ indent_style = space
indent_size = 2

[*.md]
indent_size = 2
trim_trailing_whitespace = false

[*.yml]
indent_style = space
indent_size = 2

[{Makefile,go.mod,go.sum,*.go,.gitmodules}]
indent_style = tab
indent_size = 4

[*.sh]
indent_size = 4

[Dockerfile]
indent_size = 4
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language: [ 'go', 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

Expand All @@ -48,11 +48,11 @@ jobs:
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
Expand All @@ -61,7 +61,7 @@ jobs:
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI to Docker Hub

on:
push:
# branches:
# - "master"
tags:
- "v*"
# pull_request:
# branches:
# - "master"

jobs:
docker:
if: github.repository == 'ArtalkJS/Artalk'
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@master
- run: |
git fetch --prune --unshallow --tags -f
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master

# Docker tag 值生成
# https://github.com/docker/metadata-action
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/artalk
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
# 编译多平台
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
platforms: 'amd64,arm64' # 'all'

# 缓存 Docker
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# build docker image
# https://github.com/docker/build-push-action
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./
file: ./Dockerfile
platforms: 'linux/amd64,linux/arm64' # ',linux/arm/v7'
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# 缓存
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
49 changes: 49 additions & 0 deletions .github/workflows/docs-cn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: China Mirror Deploy

on:
push:
branches:
- "master"

jobs:
deploy:
if: github.repository == 'ArtalkJS/Artalk'

runs-on: ubuntu-latest

defaults:
run:
working-directory: ./docs # set for building docs

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

- name: Use pnpm
uses: pnpm/[email protected]
with:
version: 7.2.1

- name: Set node version to 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://registry.npmjs.org/
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm docs:build

- name: Deploy
uses: TencentCloud/cos-action@v1
with:
secret_id: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
secret_key: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
cos_bucket: ${{ secrets.DOCS_CN_COS_BUCKET }}
cos_region: ${{ secrets.DOCS_CN_COS_REGION }}
local_path: .vitepress/dist/
remote_path: /
clean: true
10 changes: 8 additions & 2 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ jobs:
publish:
# prevents this action from running on forks
if: github.repository == 'ArtalkJS/Artalk'

runs-on: ubuntu-latest

defaults:
run:
working-directory: ./ui # set for building UI

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

- name: Use pnpm
uses: pnpm/[email protected]
with:
version: 7.11.0
version: 7.25.0

- name: Set node version to 16.x
uses: actions/setup-node@v3
Expand All @@ -34,7 +40,7 @@ jobs:
run: pnpm build

- name: Publish
run: cd packages/artalk && pnpm publish --no-git-checks
run: pnpm publish -F artalk --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down
Loading

0 comments on commit d52b2f5

Please sign in to comment.