Skip to content

Commit

Permalink
workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
akellbl4 committed Jul 13, 2022
1 parent 3c90f6a commit 24259ca
Show file tree
Hide file tree
Showing 374 changed files with 906 additions and 950 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ on:

jobs:
build-images:
name: Build Docker images
runs-on: ubuntu-latest

steps:
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/ci-frontend-size-limit.yml

This file was deleted.

77 changes: 51 additions & 26 deletions .github/workflows/ci-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@ name: frontend
on:
push:
branches:
tags:
- master
paths:
- ".github/workflows/ci-frontend.yml"
- "frontend/**"
- "frontend/apps/remark42/**"
- "!**.md"
pull_request:
paths:
- ".github/workflows/ci-frontend.yml"
- "frontend/**"
- "frontend/apps/remark42/**"
- "!**.md"

jobs:
check-translations:
translations-check:
name: Translations files check
runs-on: ubuntu-latest
strategy:
matrix:
node: [16.15.1]

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

- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

Expand All @@ -51,25 +52,26 @@ jobs:
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm i --loglevel warn
run: pnpm i
working-directory: ./frontend

- name: Run translations check
run: pnpm run check:translation
working-directory: ./frontend
run: pnpm run translation-check
working-directory: ./frontend/apps/remark42

check-typescript:
type-check:
name: Type check
runs-on: ubuntu-latest
strategy:
matrix:
node: [16.15.1]

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

- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

Expand All @@ -94,25 +96,26 @@ jobs:
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm i --loglevel warn
run: pnpm i
working-directory: ./frontend

- name: Run type check
run: pnpm run check:types
working-directory: ./frontend
run: pnpm run type-check
working-directory: ./frontend/apps/remark42

lint:
name: Eslint & Stylelint
runs-on: ubuntu-latest
strategy:
matrix:
node: [16.15.1]

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

- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

Expand All @@ -137,25 +140,47 @@ jobs:
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm i --loglevel warn
run: pnpm i
working-directory: ./frontend

- name: Run linters
run: pnpm run lint
working-directory: ./frontend
working-directory: ./frontend/apps/remark42

size-limit:
runs-on: ubuntu-latest
env:
CI_JOB_NUMBER: 1
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2.0.1
id: pnpm-install
with:
version: 7
run_install: false

- name: Check bundle size
uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
directory: ./frontend/apps/remark42

test:
name: Tests & Coverage
runs-on: ubuntu-latest
strategy:
matrix:
node: [16.15.1]

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

- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

Expand All @@ -180,14 +205,14 @@ jobs:
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm i --loglevel warn
run: pnpm i
working-directory: ./frontend

- name: Collect tests coverage
run: pnpm run test --coverage
working-directory: ./frontend
- name: Test & Coverage
run: pnpm run coverage
working-directory: ./frontend/apps/remark42

- name: Submit coverage
run: ${{ github.workspace }}/frontend/node_modules/.bin/codecov
run: ${{ github.workspace }}/frontend/apps/remark42/node_modules/.bin/codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/ci-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ on:
- "site/**"

jobs:

build-site:
name: Build site
runs-on: ubuntu-latest

steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-test-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- "!**.md"
jobs:
test-backend:
name: Tests & Coverage
runs-on: ubuntu-latest

steps:
Expand Down
79 changes: 37 additions & 42 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
FROM --platform=$BUILDPLATFORM node:16.15.1-alpine AS frontend-deps

ARG SKIP_FRONTEND_TEST
ARG SKIP_FRONTEND_BUILD

WORKDIR /srv/frontend

COPY ./frontend/package.json ./frontend/pnpm-lock.yaml ./frontend/pnpm-workspace.yaml /srv/frontend
COPY ./frontend/apps/remark42/package.json /srv/frontend/apps/remark42/package.json

RUN \
if [[ -z "$SKIP_FRONTEND_BUILD" || -z "$SKIP_FRONTEND_TEST" ]]; then \
apk add --no-cache --update git && \
npm i -g pnpm; \
fi

RUN --mount=type=cache,id=pnpm,target=/root/.pnpm-store/v3 \
if [[ -z "$SKIP_FRONTEND_BUILD" || -z "$SKIP_FRONTEND_TEST" ]]; then \
pnpm i; \
fi

FROM --platform=$BUILDPLATFORM frontend-deps AS build-frontend

ARG SKIP_FRONTEND_TEST
ARG SKIP_FRONTEND_BUILD
ENV CI=true

WORKDIR /srv/frontend

COPY ./frontend/ /srv/frontend/

RUN [ -n "$SKIP_FRONTEND_TEST" ] && pnpm checks
RUN [ -n "$SKIP_FRONTEND_BUILD" ] && pnpm build

FROM umputun/baseimage:buildgo-v1.9.1 as build-backend

ARG CI
Expand Down Expand Up @@ -25,53 +59,14 @@ RUN \
cat /profile.cov_tmp | grep -v "_mock.go" > /profile.cov ; \
golangci-lint run --config ../.golangci.yml ./... ; \
else \
echo "skip backend tests and linter" \
echo "skip backend tests and linter" \
; fi

RUN \
version="$(/script/version.sh)" && \
echo "version=$version" && \
go build -o remark42 -ldflags "-X main.revision=${version} -s -w" ./app

FROM --platform=$BUILDPLATFORM node:16.15.1-alpine as build-frontend-deps

ARG CI
ARG SKIP_FRONTEND_BUILD
ENV HUSKY_SKIP_INSTALL=true

RUN if [ -z "$SKIP_FRONTEND_BUILD" ] ; then \
apk add --no-cache --update git \
; fi
ADD frontend/package.json /srv/frontend/package.json
ADD frontend/package-lock.json /srv/frontend/package-lock.json
WORKDIR /srv/frontend
RUN if [ -z "$SKIP_FRONTEND_BUILD" ] ; then \
npm i -g pnpm && \
CI=true pnpm i --loglevel warn \
else \
echo "skip frontend build" \
; fi

FROM --platform=$BUILDPLATFORM node:16.15.1-alpine as build-frontend

ARG CI
ARG SKIP_FRONTEND_TEST
ARG SKIP_FRONTEND_BUILD
ARG NODE_ENV=production

COPY --from=build-frontend-deps /srv/frontend/node_modules /srv/frontend/node_modules
ADD frontend /srv/frontend
WORKDIR /srv/frontend
RUN mkdir public
RUN if [ -z "$SKIP_FRONTEND_BUILD" ] ; then \
if [ -z "$SKIP_FRONTEND_TEST" ] ; then \
npm run lint test check; \
else \
echo "skip frontend tests and lint" ; npm run build \
; fi \
; fi
RUN rm -rf ./node_modules

FROM umputun/baseimage:app-v1.9.1

WORKDIR /srv
Expand All @@ -84,7 +79,7 @@ RUN chmod +x /entrypoint.sh /usr/local/bin/backup /usr/local/bin/restore /usr/lo

COPY --from=build-backend /build/backend/remark42 /srv/remark42
COPY --from=build-backend /build/backend/templates /srv
COPY --from=build-frontend /srv/frontend/public/ /srv/web
COPY --from=build-frontend /srv/frontend/apps/remark42/public/ /srv/web/
COPY docker-init.sh /srv/init.sh
RUN chown -R app:app /srv
RUN ln -s /srv/remark42 /usr/bin/remark42
Expand All @@ -94,4 +89,4 @@ HEALTHCHECK --interval=30s --timeout=3s CMD curl --fail http://localhost:8080/pi


RUN chmod +x /srv/init.sh
CMD ["/srv/remark42", "server"]
CMD ["/srv/remark42", "server"]
Loading

0 comments on commit 24259ca

Please sign in to comment.