forked from ArtalkJS/Artalk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: build scripts and CI tests
Signed-off-by: qwqcode <[email protected]>
- Loading branch information
Showing
19 changed files
with
188 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ArtalkGo | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,26 @@ | ||
# https://circleci.com/docs/2.0/configuration-reference | ||
version: 2.1 | ||
|
||
# Define a job to be invoked later in a workflow. | ||
jobs: | ||
test: | ||
working_directory: ~/go/src/github.com/ArtalkJS/ArtalkGo | ||
environment: | ||
GO111MODULE: "on" | ||
docker: | ||
- image: cimg/go:1.19 | ||
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 | ||
# 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: | ||
path-filtering: circleci/[email protected] | ||
|
||
# Invoke jobs via workflows | ||
workflows: | ||
tests: | ||
setup: | ||
jobs: | ||
- test | ||
- path-filtering/filter: | ||
mapping: | | ||
(cmd|internal|server|pkg|test)/.* trigger-app true | ||
main.go|go.mod|go.sum|artalk-go.example.yml trigger-app true | ||
(ui)/.* trigger-ui true | ||
base-revision: master # git branch name | ||
config-path: .circleci/conditional_config.yml | ||
filters: | ||
branches: | ||
ignore: | ||
- gh-pages |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ on: | |
|
||
jobs: | ||
docker: | ||
if: github.repository == 'ArtalkJS/Artalk' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
Oops, something went wrong.