Skip to content

Commit b9e8046

Browse files
committed
fix: i don't know whether work
refer to lowlighter#1724
1 parent 2bbb87b commit b9e8046

File tree

4 files changed

+3174
-2079
lines changed

4 files changed

+3174
-2079
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ name: Build, test and analyze
22

33
on:
44
pull_request:
5-
branches: [ master ]
5+
branches: [master]
66
workflow_call:
77

88
jobs:
9-
109
# Run linter to ensure new code respect coding rules
1110
lint:
1211
name: Lint code
@@ -33,7 +32,7 @@ jobs:
3332
build:
3433
name: Build and test
3534
runs-on: ubuntu-latest
36-
needs: [ lint ]
35+
needs: [lint]
3736
steps:
3837
- name: Checkout repository
3938
uses: actions/checkout@v3
@@ -49,13 +48,13 @@ jobs:
4948
- name: Run tests
5049
env:
5150
GIT_REF: ${{ github.head_ref || 'master' }}
52-
run: docker run --rm --entrypoint="" lowlighter/metrics:$(echo $GIT_REF | sed 's/[^a-z]/-/g') npm run test-metrics
51+
run: docker run --rm --entrypoint="" lowlighter/metrics:$(echo $GIT_REF | sed 's/[^a-z]/-/g') sh -xc 'npm install --no-save && exec npm run test-metrics'
5352

5453
# Run CodeQL on branch
5554
analyze:
5655
name: Analyze code
5756
runs-on: ubuntu-latest
58-
needs: [ lint ]
57+
needs: [lint]
5958
steps:
6059
- name: Checkout repository
6160
uses: actions/checkout@v3
@@ -65,4 +64,4 @@ jobs:
6564
languages: javascript
6665
config-file: ./.github/config/codeql.yml
6766
- name: Analyze code
68-
uses: github/codeql-action/analyze@v2
67+
uses: github/codeql-action/analyze@v2

Dockerfile

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
1+
# syntax=docker/dockerfile:1.16
2+
13
# Base image
2-
FROM node:20-bookworm-slim
4+
FROM node:22
5+
6+
# Install latest chrome dev package, fonts to support major charsets and skip chromium download on puppeteer install
7+
# Based on https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-in-docker
8+
RUN set -x \
9+
&& apt-get update \
10+
&& apt-get install -y --no-install-recommends wget ca-certificates \
11+
&& wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
12+
&& apt-get install -y --no-install-recommends ./google-chrome-stable_current_amd64.deb fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
13+
&& rm -rf ./google-chrome-stable_current_amd64.deb /var/lib/apt/lists/*
14+
15+
# Install deno for miscellaneous scripts
16+
# TODO: pin major deno version
17+
COPY --from=denoland/deno:bin /deno /usr/local/bin/deno
18+
19+
# Install licensed through pkgx
20+
# TODO: pin major pkgx version
21+
COPY --from=pkgxdev/pkgx:busybox /usr/local/bin/pkgx /usr/local/bin/pkgx
22+
COPY --chmod=+x <<EOF /usr/local/bin/licensed
23+
#!/usr/bin/env -S pkgx --shebang --quiet +github.com/licensee/licensed@5 -- licensed
24+
EOF
25+
RUN licensed --version
26+
27+
# Environment variables
28+
ENV PUPPETEER_SKIP_DOWNLOAD="true"
29+
ENV PUPPETEER_EXECUTABLE_PATH="/usr/bin/google-chrome-stable"
330

431
# Copy repository
5-
COPY . /metrics
632
WORKDIR /metrics
33+
COPY . .
734

8-
# Setup
9-
RUN chmod +x /metrics/source/app/action/index.mjs \
10-
# Install latest chrome dev package, fonts to support major charsets and skip chromium download on puppeteer install
11-
# Based on https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker
12-
&& apt-get update \
13-
&& apt-get install -y wget gnupg ca-certificates libgconf-2-4 \
14-
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
15-
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
16-
&& apt-get update \
17-
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 libx11-xcb1 libxtst6 lsb-release --no-install-recommends \
18-
# Install deno for miscellaneous scripts
19-
&& apt-get install -y curl unzip \
20-
&& curl -fsSL https://deno.land/x/install/install.sh | DENO_INSTALL=/usr/local sh \
21-
# Install ruby to support github licensed gem
22-
&& apt-get install -y ruby-full git g++ cmake pkg-config libssl-dev xz-utils \
23-
&& gem install licensed \
24-
# Install python for node-gyp
25-
&& apt-get install -y python3 \
26-
# Clean apt/lists
27-
&& rm -rf /var/lib/apt/lists/* \
28-
# Install node modules and rebuild indexes
35+
# Install node modules and rebuild indexes
36+
RUN set -x \
37+
&& which "${PUPPETEER_EXECUTABLE_PATH}" \
2938
&& npm ci \
30-
&& npm run build
31-
32-
# Environment variables
33-
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
34-
ENV PUPPETEER_BROWSER_PATH "google-chrome-stable"
39+
&& npm run build \
40+
&& npm prune --omit=dev
3541

3642
# Execute GitHub action
37-
ENTRYPOINT node /metrics/source/app/action/index.mjs
43+
ENTRYPOINT ["node", "/metrics/source/app/action/index.mjs"]

0 commit comments

Comments
 (0)