Skip to content

Commit

Permalink
refactor: build scripts and CI tests
Browse files Browse the repository at this point in the history
Signed-off-by: qwqcode <[email protected]>
  • Loading branch information
qwqcode committed Jan 16, 2023
1 parent 802749f commit d229a62
Show file tree
Hide file tree
Showing 19 changed files with 188 additions and 344 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/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
54 changes: 20 additions & 34 deletions .circleci/config.yml
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
31 changes: 0 additions & 31 deletions .circleci/config_ui.yml

This file was deleted.

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
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
74 changes: 0 additions & 74 deletions .github/workflows/codeql_ui.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:

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

steps:
Expand Down
8 changes: 7 additions & 1 deletion .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 Down
Loading

0 comments on commit d229a62

Please sign in to comment.