From bb4ac1976c362915aba4faa53cf33f4b5e243146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20B=C3=BCttner?= Date: Mon, 6 May 2024 01:13:18 +0200 Subject: [PATCH 1/3] Add current containers fixes https://github.com/idrinth-api-bench/api-bench/issues/992 --- build/Dockerfile | 83 +++++++++++++++++++++++++++++++++ build/README.md | 12 +++++ framework/Dockerfile | 40 ++++++++++++++++ framework/README.md | 13 ++++++ gitea-action/Dockerfile | 43 +++++++++++++++++ gitea-action/README.md | 13 ++++++ gitlab-runner/Dockerfile | 43 +++++++++++++++++ gitlab-runner/README.md | 13 ++++++ history-microservice/Dockerfile | 41 ++++++++++++++++ history-microservice/README.md | 13 ++++++ history-website/Dockerfile | 43 +++++++++++++++++ history-website/README.md | 13 ++++++ history-website/nginx.conf | 8 ++++ 13 files changed, 378 insertions(+) create mode 100644 build/Dockerfile create mode 100644 build/README.md create mode 100644 framework/Dockerfile create mode 100644 framework/README.md create mode 100644 gitea-action/Dockerfile create mode 100644 gitea-action/README.md create mode 100644 gitlab-runner/Dockerfile create mode 100644 gitlab-runner/README.md create mode 100644 history-microservice/Dockerfile create mode 100644 history-microservice/README.md create mode 100644 history-website/Dockerfile create mode 100644 history-website/README.md create mode 100644 history-website/nginx.conf diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..07cc643 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,83 @@ +FROM node:21.7.3-alpine AS node + +ARG BUILD_VERSION +ARG BUILD_TIME +ARG BUILD_HASH + +LABEL author="Björn 'Idrinth' Büttner" +LABEL maintainer="webmaster@idrinth-api-ben.ch" +LABEL org.label-schema.name="idrinth/api-bench/build" +LABEL org.label-schema.description="An image building the @idrinth/api-bench packages." +LABEL org.label-schema.url="https://idrinth-api-ben.ch" +LABEL org.label-schema.vcs-url="https://github.com/idrinth/api-bench" +LABEL org.label-schema.version=$BUILD_VERSION +LABEL org.label-schema.build-date=$BUILD_TIME +LABEL org.label-schema.vcs-ref=$BUILD_HASH +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.vendor="Björn 'Idrinth' Büttner" +LABEL org.opencontainers.image.created=$BUILD_TIME +LABEL org.opencontainers.image.authors="webmaster@idrinth-api-ben.ch" +LABEL org.opencontainers.image.url="https://idrinth-api-ben.ch" +LABEL org.opencontainers.image.documentation="https://idrinth-api-ben.ch" +LABEL org.opencontainers.image.source="https://github.com/idrinth/api-bench" +LABEL org.opencontainers.image.version=$BUILD_VERSION +LABEL org.opencontainers.image.revision=$BUILD_HASH +LABEL org.opencontainers.image.vendor="Björn 'Idrinth' Büttner" +LABEL org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.title="idrinth/api-bench/build" +LABEL org.opencontainers.image.description="An image building the @idrinth/api-bench packages." + +ENV IDRINTH_API_BENCH_VERSION=$BUILD_VERSION +ENV IDRINTH_API_BENCH_BUILT=$BUILD_TIME + +RUN apk add --no-cache "git=2.43.0-r0" \ + && npm install -g clean-modules@3.0.5 \ + && mkdir /api-bench \ + && git clone https://github.com/idrinth/api-bench /api-bench +WORKDIR /api-bench +RUN git fetch --tags \ + && git checkout ${BUILD_VERSION} + +WORKDIR /api-bench/framework +RUN npm ci \ + && ls -la \ + && npm run language \ + && npm run tsc \ + && npm prune --production \ + && (rm ./src/**/*.ts || true) \ + && (rm ./node_modules/**/*.ts || true) \ + && (rm ./README.md || true) \ + && (rm ./index.ts || true) \ + && (rm ./tsconfig.json || true) \ + && (rm ./LICENSE || true) \ + && (rm -r ./typings || true) \ + && (rm -r ./integration || true) \ + && (rm -r ./property || true) \ + && (rm -r ./test || true) \ + && (rm -r ./tools || true) \ + && (rm -r ./fixtures || true) \ + && (rm -r ./language || true) \ + && clean-modules clean --yes \ + && mkdir -p /usr/local/lib/node_modules/@idrinth/api-bench \ + && cp --recursive /api-bench/framework/* /usr/local/lib/node_modules/@idrinth/api-bench/ + +WORKDIR /api-bench/history-microservice +RUN npm ci \ + && npm run tsc \ + && npm prune --production \ + && (rm /api-bench/history-microservice/README.md || true) \ + && (rm /api-bench/history-microservice/src/**/*.ts || true) \ + && (rm /api-bench/history-microservice/src/**/*.ts || true) \ + && clean-modules clean --yes \ + && mkdir -p /project/@idrinth/api-bench/history-microservice \ + && cp --recursive /api-bench/history-microservice/* /project/@idrinth/api-bench/history-microservice/ \ + && cp /api-bench/history-microservice/.env /project/@idrinth/api-bench/history-microservice/ + +WORKDIR /api-bench/history-website +RUN npm ci \ + && npm run language \ + && npm run build \ + && mkdir -p /project/@idrinth/api-bench/history-website \ + && cp --recursive /api-bench/history-website/dist/* /project/@idrinth/api-bench/history-website/ + +RUN rm -r /api-bench diff --git a/build/README.md b/build/README.md new file mode 100644 index 0000000..49fb61f --- /dev/null +++ b/build/README.md @@ -0,0 +1,12 @@ +# @idrinth/api-bench build on alpine + +This image builds api-bench on alpine and is mostly for internal usage. + +## Tags + +There are four groups of tags + +- Single number `2` is the latest of that major version +- Single number `2.6` is the latest of that feature version +- Triple number `2.6.1` is the exact version +- `latest` is the latest minor version diff --git a/framework/Dockerfile b/framework/Dockerfile new file mode 100644 index 0000000..16ba7bb --- /dev/null +++ b/framework/Dockerfile @@ -0,0 +1,40 @@ +ARG BUILD_VERSION + +FROM idrinth/api-bench-build:${BUILD_VERSION} AS build +FROM node:21.7.3-alpine AS node + +ARG BUILD_VERSION +ARG BUILD_TIME +ARG BUILD_HASH + +LABEL author="Björn 'Idrinth' Büttner" +LABEL maintainer="webmaster@idrinth-api-ben.ch" +LABEL org.label-schema.name="idrinth/api-bench" +LABEL org.label-schema.description="An image prepared for api-bench usage via global install." +LABEL org.label-schema.url="https://idrinth-api-ben.ch" +LABEL org.label-schema.vcs-url="https://github.com/idrinth/api-bench" +LABEL org.label-schema.version=$BUILD_VERSION +LABEL org.label-schema.build-date=$BUILD_TIME +LABEL org.label-schema.vcs-ref=$BUILD_HASH +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.vendor="Björn 'Idrinth' Büttner" +LABEL org.opencontainers.image.created=$BUILD_TIME +LABEL org.opencontainers.image.authors="webmaster@idrinth-api-ben.ch" +LABEL org.opencontainers.image.url="https://idrinth-api-ben.ch" +LABEL org.opencontainers.image.documentation="https://idrinth-api-ben.ch" +LABEL org.opencontainers.image.source="https://github.com/idrinth/api-bench" +LABEL org.opencontainers.image.version=$BUILD_VERSION +LABEL org.opencontainers.image.revision=$BUILD_HASH +LABEL org.opencontainers.image.vendor="Björn 'Idrinth' Büttner" +LABEL org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.title="idrinth/api-bench" +LABEL org.opencontainers.image.description="An image prepared for api-bench usage via global install." + +ENV IDRINTH_API_BENCH_VERSION=$BUILD_VERSION +ENV IDRINTH_API_BENCH_BUILT=$BUILD_TIME + +RUN mkdir -p /usr/local/lib/node_modules/@idrinth/api-bench +COPY --from=build /usr/local/lib/node_modules/@idrinth/api-bench /usr/local/lib/node_modules/@idrinth/api-bench + +WORKDIR /project +VOLUME /project diff --git a/framework/README.md b/framework/README.md new file mode 100644 index 0000000..16fb025 --- /dev/null +++ b/framework/README.md @@ -0,0 +1,13 @@ +# @idrinth/api-bench + alpine + +This image prepares api-bench for use with a mounted volume +and brings along everything required to run API tests. + +## Tags + +There are four groups of tags + +- Single number `2` is the latest of that major version +- Single number `2.6` is the latest of that feature version +- Triple number `2.6.1` is the exact version +- `latest` is the latest minor version diff --git a/gitea-action/Dockerfile b/gitea-action/Dockerfile new file mode 100644 index 0000000..a62a7b5 --- /dev/null +++ b/gitea-action/Dockerfile @@ -0,0 +1,43 @@ +ARG BUILD_VERSION + +FROM node:21.7.3-alpine AS node +FROM idrinth/api-bench-build:${BUILD_VERSION} AS build +FROM gitea/act_runner:0.2.10 AS gitea + +COPY --from=node /usr/lib /usr/lib +COPY --from=node /usr/local/lib /usr/local/lib +COPY --from=node /usr/local/include /usr/local/include +COPY --from=node /usr/local/bin /usr/local/bin + +RUN mkdir -p /usr/local/lib/node_modules/@idrinth/api-bench +COPY --from=build /usr/local/lib/node_modules/@idrinth/api-bench /usr/local/lib/node_modules/@idrinth/api-bench + +ARG BUILD_VERSION +ARG BUILD_TIME +ARG BUILD_HASH + +LABEL author="Björn 'Idrinth' Büttner" +LABEL maintainer="webmaster@idrinth-api-ben.ch" +LABEL org.label-schema.name="idrinth/api-bench/gitea-action" +LABEL org.label-schema.description="A gitea action prepared for api-bench usage via global install." +LABEL org.label-schema.url="https://idrinth-api-ben.ch" +LABEL org.label-schema.vcs-url="https://github.com/idrinth/api-bench" +LABEL org.label-schema.version=$BUILD_VERSION +LABEL org.label-schema.build-date=$BUILD_TIME +LABEL org.label-schema.vcs-ref=$BUILD_HASH +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.vendor="Björn 'Idrinth' Büttner" +LABEL org.opencontainers.image.created=$BUILD_TIME +LABEL org.opencontainers.image.authors="webmaster@idrinth-api-ben.ch" +LABEL org.opencontainers.image.url="https://idrinth-api-ben.ch" +LABEL org.opencontainers.image.documentation="https://idrinth-api-ben.ch" +LABEL org.opencontainers.image.source="https://github.com/idrinth/api-bench" +LABEL org.opencontainers.image.version=$BUILD_VERSION +LABEL org.opencontainers.image.revision=$BUILD_HASH +LABEL org.opencontainers.image.vendor="Björn 'Idrinth' Büttner" +LABEL org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.title="idrinth/api-bench/gitea-action" +LABEL org.opencontainers.image.description="A gitea action prepared for api-bench usage via global install." + +ENV IDRINTH_API_BENCH_VERSION=$BUILD_VERSION +ENV IDRINTH_API_BENCH_BUILT=$BUILD_TIME diff --git a/gitea-action/README.md b/gitea-action/README.md new file mode 100644 index 0000000..5d589bd --- /dev/null +++ b/gitea-action/README.md @@ -0,0 +1,13 @@ +# @idrinth/api-bench + gitea/act_runner + alpine + +This image prepares an action for use in gitea, +that brings along everything required to run API tests. + +## Tags + +There are four groups of tags + +- Single number `2` is the latest of that major version +- Single number `2.6` is the latest of that feature version +- Triple number `2.6.1` is the exact version +- `latest` is the latest minor version diff --git a/gitlab-runner/Dockerfile b/gitlab-runner/Dockerfile new file mode 100644 index 0000000..afdf278 --- /dev/null +++ b/gitlab-runner/Dockerfile @@ -0,0 +1,43 @@ +ARG BUILD_VERSION + +FROM idrinth/api-bench-build:${BUILD_VERSION} AS build +FROM node:21.7.3-alpine AS node +FROM gitlab/gitlab-runner:alpine3.19-v16.10.0 AS gitlab + +COPY --from=node /usr/lib /usr/lib +COPY --from=node /usr/local/lib /usr/local/lib +COPY --from=node /usr/local/include /usr/local/include +COPY --from=node /usr/local/bin /usr/local/bin + +RUN mkdir -p /usr/local/lib/node_modules/@idrinth/api-bench +COPY --from=build /usr/local/lib/node_modules/@idrinth/api-bench /usr/local/lib/node_modules/@idrinth/api-bench + +ARG BUILD_VERSION +ARG BUILD_TIME +ARG BUILD_HASH + +LABEL author="Björn 'Idrinth' Büttner" +LABEL maintainer="webmaster@idrinth-api-ben.ch" +LABEL org.label-schema.name="idrinth/api-bench/gitlab-runner" +LABEL org.label-schema.description="A gitlab runner prepared for api-bench usage via global install." +LABEL org.label-schema.url="https://idrinth-api-ben.ch" +LABEL org.label-schema.vcs-url="https://github.com/idrinth/api-bench" +LABEL org.label-schema.version=$BUILD_VERSION +LABEL org.label-schema.build-date=$BUILD_TIME +LABEL org.label-schema.vcs-ref=$BUILD_HASH +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.vendor="Björn 'Idrinth' Büttner" +LABEL org.opencontainers.image.created=$BUILD_TIME +LABEL org.opencontainers.image.authors="webmaster@idrinth-api-ben.ch" +LABEL org.opencontainers.image.url="https://idrinth-api-ben.ch" +LABEL org.opencontainers.image.documentation="https://idrinth-api-ben.ch" +LABEL org.opencontainers.image.source="https://github.com/idrinth/api-bench" +LABEL org.opencontainers.image.version=$BUILD_VERSION +LABEL org.opencontainers.image.revision=$BUILD_HASH +LABEL org.opencontainers.image.vendor="Björn 'Idrinth' Büttner" +LABEL org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.title="idrinth/api-bench/gitlab-runner" +LABEL org.opencontainers.image.description="A gitlab runner prepared for api-bench usage via global install." + +ENV IDRINTH_API_BENCH_VERSION=$BUILD_VERSION +ENV IDRINTH_API_BENCH_BUILT=$BUILD_TIME diff --git a/gitlab-runner/README.md b/gitlab-runner/README.md new file mode 100644 index 0000000..8b46ef6 --- /dev/null +++ b/gitlab-runner/README.md @@ -0,0 +1,13 @@ +# @idrinth/api-bench + gitlab/gitlab-runner + alpine + +This image prepares a runner for use in gitlab, +that brings along everything required to run API tests. + +## Tags + +There are four groups of tags + +- Single number `2` is the latest of that major version +- Single number `2.6` is the latest of that feature version +- Triple number `2.6.1` is the exact version +- `latest` is the latest minor version diff --git a/history-microservice/Dockerfile b/history-microservice/Dockerfile new file mode 100644 index 0000000..9995c11 --- /dev/null +++ b/history-microservice/Dockerfile @@ -0,0 +1,41 @@ +ARG BUILD_VERSION + +FROM idrinth/api-bench-build:${BUILD_VERSION} AS build +FROM node:21.7.3-alpine AS node + +ARG BUILD_VERSION +ARG BUILD_TIME +ARG BUILD_HASH + +LABEL author="Björn 'Idrinth' Büttner" +LABEL maintainer="webmaster@idrinth-api-ben.ch" +LABEL org.label-schema.name="idrinth/api-bench/history-microservice" +LABEL org.label-schema.description="A microservice prepared for monitoring api-bench results." +LABEL org.label-schema.url="https://idrinth-api-ben.ch" +LABEL org.label-schema.vcs-url="https://github.com/idrinth/api-bench" +LABEL org.label-schema.version=$BUILD_VERSION +LABEL org.label-schema.build-date=$BUILD_TIME +LABEL org.label-schema.vcs-ref=$BUILD_HASH +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.vendor="Björn 'Idrinth' Büttner" +LABEL org.opencontainers.image.created=$BUILD_TIME +LABEL org.opencontainers.image.authors="webmaster@idrinth-api-ben.ch" +LABEL org.opencontainers.image.url="https://idrinth-api-ben.ch" +LABEL org.opencontainers.image.documentation="https://idrinth-api-ben.ch" +LABEL org.opencontainers.image.source="https://github.com/idrinth/api-bench" +LABEL org.opencontainers.image.version=$BUILD_VERSION +LABEL org.opencontainers.image.revision=$BUILD_HASH +LABEL org.opencontainers.image.vendor="Björn 'Idrinth' Büttner" +LABEL org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.title="idrinth/api-bench/history-microservice" +LABEL org.opencontainers.image.description="A microservice prepared for monitoring api-bench results." + +ENV IDRINTH_API_BENCH_VERSION=$BUILD_VERSION +ENV IDRINTH_API_BENCH_BUILT=$BUILD_TIME + +WORKDIR /project +COPY --from=build /project/@idrinth/api-bench/history-microservice /project + +EXPOSE 80 + +ENTRYPOINT ["node", "/project/index.js"] diff --git a/history-microservice/README.md b/history-microservice/README.md new file mode 100644 index 0000000..b7ee6a5 --- /dev/null +++ b/history-microservice/README.md @@ -0,0 +1,13 @@ +# @idrinth/api-bench/history-microservice + alpine + +This image prepares the history microservice for usage with the monitoring +website. + +## Tags + +There are four groups of tags + +- Single number `2` is the latest of that major version +- Single number `2.6` is the latest of that feature version +- Triple number `2.6.1` is the exact version +- `latest` is the latest minor version diff --git a/history-website/Dockerfile b/history-website/Dockerfile new file mode 100644 index 0000000..e384751 --- /dev/null +++ b/history-website/Dockerfile @@ -0,0 +1,43 @@ +ARG BUILD_VERSION + +FROM idrinth/api-bench-build:${BUILD_VERSION} AS build +FROM nginx:stable-alpine3.17-slim AS nginx + +ARG BUILD_VERSION +ARG BUILD_TIME +ARG BUILD_HASH + +LABEL author="Björn 'Idrinth' Büttner" +LABEL maintainer="webmaster@idrinth-api-ben.ch" +LABEL org.label-schema.name="idrinth/api-bench/history-website" +LABEL org.label-schema.description="A website prepared for monitoring api-bench results." +LABEL org.label-schema.url="https://idrinth-api-ben.ch" +LABEL org.label-schema.vcs-url="https://github.com/idrinth/api-bench" +LABEL org.label-schema.version=$BUILD_VERSION +LABEL org.label-schema.build-date=$BUILD_TIME +LABEL org.label-schema.vcs-ref=$BUILD_HASH +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.vendor="Björn 'Idrinth' Büttner" +LABEL org.opencontainers.image.created=$BUILD_TIME +LABEL org.opencontainers.image.authors="webmaster@idrinth-api-ben.ch" +LABEL org.opencontainers.image.url="https://idrinth-api-ben.ch" +LABEL org.opencontainers.image.documentation="https://idrinth-api-ben.ch" +LABEL org.opencontainers.image.source="https://github.com/idrinth/api-bench" +LABEL org.opencontainers.image.version=$BUILD_VERSION +LABEL org.opencontainers.image.revision=$BUILD_HASH +LABEL org.opencontainers.image.vendor="Björn 'Idrinth' Büttner" +LABEL org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.title="idrinth/api-bench/history-website" +LABEL org.opencontainers.image.description="A website prepared for monitoring api-bench results." + +ENV IDRINTH_API_BENCH_VERSION=$BUILD_VERSION +ENV IDRINTH_API_BENCH_BUILT=$BUILD_TIME + +COPY nginx.conf /etc/nginx/nginx.conf + +WORKDIR /var/www/html +COPY --from=build /project/@idrinth/api-bench/history-website /var/www/html + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/history-website/README.md b/history-website/README.md new file mode 100644 index 0000000..ffeeff7 --- /dev/null +++ b/history-website/README.md @@ -0,0 +1,13 @@ +# @idrinth/api-bench/history-website + alpine + +This image prepares the history website for usage with the monitoring +microservice. + +## Tags + +There are four groups of tags + +- Single number `2` is the latest of that major version +- Single number `2.6` is the latest of that feature version +- Triple number `2.6.1` is the exact version +- `latest` is the latest minor version diff --git a/history-website/nginx.conf b/history-website/nginx.conf new file mode 100644 index 0000000..6effebb --- /dev/null +++ b/history-website/nginx.conf @@ -0,0 +1,8 @@ +server { + listen 80; + + location / { + root /var/www/html; + index index.html; + } +} From 86d2ddab08a2ed1d306540f9ccd7f6e702f63a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20B=C3=BCttner?= Date: Mon, 6 May 2024 01:17:32 +0200 Subject: [PATCH 2/3] Add current containers fixes https://github.com/idrinth-api-bench/api-bench/issues/992 --- tools/.eslintrc.yml | 4 +++ tools/rebuild-images.js | 54 +++++++++++++++++++++++++++++++++++++++++ tools/src/constants.js | 11 +++++++++ tools/src/exec.js | 20 +++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 tools/.eslintrc.yml create mode 100644 tools/rebuild-images.js create mode 100644 tools/src/constants.js create mode 100644 tools/src/exec.js diff --git a/tools/.eslintrc.yml b/tools/.eslintrc.yml new file mode 100644 index 0000000..e039fda --- /dev/null +++ b/tools/.eslintrc.yml @@ -0,0 +1,4 @@ +env: + node: true +rules: + no-console: off diff --git a/tools/rebuild-images.js b/tools/rebuild-images.js new file mode 100644 index 0000000..eb7ff09 --- /dev/null +++ b/tools/rebuild-images.js @@ -0,0 +1,54 @@ +import { + rmSync, + writeFileSync, +} from 'fs'; +import exec from './src/exec.js'; +import readline from 'readline'; +import { + EXIT_SUCCESS, +} from './src/constants.js'; + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, +},); +rl.question('Versions(space separated): ', (versions,) => { + rl.question('Docker password: ', (password,) => { + writeFileSync('./pw', password,); + exec('cat pw | docker login -u idrinth --password-stdin', true,); + rmSync('./pw',); + rl.question('Images(space separated): ', (images,) => { + for (const image of images.split(' ',)) { + for (const version of versions.split(' ',)) { + if (version && version.match(/^\d+\.\d+\.\d+$/u,)) { + const main = version.replace(/\..+$/u, '',); + const feature = version.replace(/\.[^.]+$/u, '',); + const hash = exec('git rev-parse --short HEAD',); + const args = [ + `--build-arg="BUILD_VERSION=${ version }"`, + `--build-arg="BUILD_TIME=${ new Date().toISOString() }"`, + `--build-arg="BUILD_HASH=${ hash }"`, + ]; + const tags = [ + `-t idrinthapibench/${ image }:latest`, + `-t idrinthapibench/${ image }:${ version }`, + `-t idrinthapibench/${ image }:${ feature }`, + `-t idrinthapibench/${ image }:${ main }`, + ]; + const params = [ + ...args, + ...tags, + ]; + exec( + `docker build ${ params.join(' ',) } ${ image }`, + true, + ); + } + } + exec(`docker push -a idrinthapibench/${ image }`, true,); + } + exec('docker image prune --force', true,); + process.exit(EXIT_SUCCESS,); + },); + },); +},); diff --git a/tools/src/constants.js b/tools/src/constants.js new file mode 100644 index 0000000..5f8d915 --- /dev/null +++ b/tools/src/constants.js @@ -0,0 +1,11 @@ +export const FIRST_ARGUMENT = 2; +export const ARRAY_FIRST = 0; +export const ARRAY_SECOND = 1; +export const EXIT_SUCCESS = 0; +export const EXIT_FAILURE = 1; +export const ARRAY_LENGTH_OFFSET = 1; +export const INDENTATION = 2; +export const EMPTY = 0; +export const ERROR_FTA_SCORE = 60; +export const WARNING_FTA_SCORE = 60; +export const PADDING_DEFAULT = 1; diff --git a/tools/src/exec.js b/tools/src/exec.js new file mode 100644 index 0000000..70fce7d --- /dev/null +++ b/tools/src/exec.js @@ -0,0 +1,20 @@ +import { + execSync, +} from 'child_process'; + +// eslint-disable-next-line no-undefined +const exec = (command, passthrough=false, logOverride = undefined,) => { + if (typeof logOverride === 'undefined') { + logOverride = command; + } + console.log(logOverride,); + const result = execSync(command, passthrough ? { + stdio: 'inherit', + } : {},) + ''; + if (! passthrough) { + console.log(result,); + } + return result; +}; + +export default exec; From 3be5670818842e1201a5bb391a1158258cc9b0e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20B=C3=BCttner?= Date: Mon, 6 May 2024 01:25:05 +0200 Subject: [PATCH 3/3] Add current containers fixes https://github.com/idrinth-api-bench/api-bench/issues/992 --- .github/FUNDING.yml | 3 ++ .github/dependabot.yml | 7 +++ .github/prace.yml | 9 ++++ .github/pull_request_template.md | 26 ++++++++++ .github/release.yml | 5 ++ .../workflows/api-bench-build.hadolint.yml | 27 ++++++++++ .../api-bench-gitea-action.hadolint.yml | 27 ++++++++++ .../api-bench-gitlab-runner.hadolint.yml | 27 ++++++++++ ...pi-bench-history-microservice.hadolint.yml | 27 ++++++++++ .../api-bench-history-website.hadolint.yml | 27 ++++++++++ .github/workflows/api-bench.hadolint.yml | 27 ++++++++++ .github/workflows/global.docker.yml | 52 +++++++++++++++++++ .../workflows/global.pull-request-size.yml | 34 ++++++++++++ .github/workflows/global.spellcheck.yml | 41 +++++++++++++++ .github/workflows/root.mdlint.yml | 41 +++++++++++++++ 15 files changed, 380 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/prace.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/release.yml create mode 100644 .github/workflows/api-bench-build.hadolint.yml create mode 100644 .github/workflows/api-bench-gitea-action.hadolint.yml create mode 100644 .github/workflows/api-bench-gitlab-runner.hadolint.yml create mode 100644 .github/workflows/api-bench-history-microservice.hadolint.yml create mode 100644 .github/workflows/api-bench-history-website.hadolint.yml create mode 100644 .github/workflows/api-bench.hadolint.yml create mode 100644 .github/workflows/global.docker.yml create mode 100644 .github/workflows/global.pull-request-size.yml create mode 100644 .github/workflows/global.spellcheck.yml create mode 100644 .github/workflows/root.mdlint.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..2d38236 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +github: +- idrinth +ko_fi: idrinth diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1bae19d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: +- package-ecosystem: npm + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 100 diff --git a/.github/prace.yml b/.github/prace.yml new file mode 100644 index 0000000..953d729 --- /dev/null +++ b/.github/prace.yml @@ -0,0 +1,9 @@ +version: 1 +body: + patterns: + - '#\d+' + error: The body has to include an issue reference like `#0` +branch: + patterns: + - 'issue-\d{1,}-[a-z0-9-]+' + error: Branch must be called `issue-{id}-{short description}` diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..06479d2 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,26 @@ +# The Pull Request is ready + +- [ ] fixes # +- [ ] all actions are passing +- [ ] only fixes a single issue + +## Overview + + + +## Review points + + + + +## Dockerfiles + +- [ ] the dockerfiles work +- [ ] the containers are as small as possible + +## Notes + + + diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..9c95664 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,5 @@ +changelog: + exclude: + authors: + - dependabot + - renovate diff --git a/.github/workflows/api-bench-build.hadolint.yml b/.github/workflows/api-bench-build.hadolint.yml new file mode 100644 index 0000000..16c57ea --- /dev/null +++ b/.github/workflows/api-bench-build.hadolint.yml @@ -0,0 +1,27 @@ +name: api-bench-build Hadolint +on: + push: + branches: + - the-one + paths: + - 'containers/api-bench-build/Dockerfile' + - '.github/workflows/api-bench-build.hadolint.yml' + pull_request: + branches: + - the-one + paths: + - 'containers/api-bench-build/Dockerfile' + - '.github/workflows/api-bench-build.hadolint.yml' +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 360 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - run: sudo apt-get install shellcheck -y + - run: wget https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64 + - run: sudo mv hadolint-Linux-x86_64 /usr/local/bin/hadolint + - run: sudo chmod +x /usr/local/bin/hadolint + - run: hadolint containers/api-bench-build/Dockerfile diff --git a/.github/workflows/api-bench-gitea-action.hadolint.yml b/.github/workflows/api-bench-gitea-action.hadolint.yml new file mode 100644 index 0000000..42f7c53 --- /dev/null +++ b/.github/workflows/api-bench-gitea-action.hadolint.yml @@ -0,0 +1,27 @@ +name: api-bench-gitea-action Hadolint +on: + push: + branches: + - the-one + paths: + - 'containers/api-bench-gitea-action/Dockerfile' + - '.github/workflows/api-bench-gitea-action.hadolint.yml' + pull_request: + branches: + - the-one + paths: + - 'containers/api-bench-gitea-action/Dockerfile' + - '.github/workflows/api-bench-gitea-action.hadolint.yml' +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 360 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - run: sudo apt-get install shellcheck -y + - run: wget https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64 + - run: sudo mv hadolint-Linux-x86_64 /usr/local/bin/hadolint + - run: sudo chmod +x /usr/local/bin/hadolint + - run: hadolint containers/api-bench-gitea-action/Dockerfile diff --git a/.github/workflows/api-bench-gitlab-runner.hadolint.yml b/.github/workflows/api-bench-gitlab-runner.hadolint.yml new file mode 100644 index 0000000..519a34c --- /dev/null +++ b/.github/workflows/api-bench-gitlab-runner.hadolint.yml @@ -0,0 +1,27 @@ +name: api-bench-gitlab-runner Hadolint +on: + push: + branches: + - the-one + paths: + - 'containers/api-bench-gitlab-runner/Dockerfile' + - '.github/workflows/api-bench-gitlab-runner.hadolint.yml' + pull_request: + branches: + - the-one + paths: + - 'containers/api-bench-gitlab-runner/Dockerfile' + - '.github/workflows/api-bench-gitlab-runner.hadolint.yml' +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 360 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - run: sudo apt-get install shellcheck -y + - run: wget https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64 + - run: sudo mv hadolint-Linux-x86_64 /usr/local/bin/hadolint + - run: sudo chmod +x /usr/local/bin/hadolint + - run: hadolint containers/api-bench-gitlab-runner/Dockerfile diff --git a/.github/workflows/api-bench-history-microservice.hadolint.yml b/.github/workflows/api-bench-history-microservice.hadolint.yml new file mode 100644 index 0000000..497f09c --- /dev/null +++ b/.github/workflows/api-bench-history-microservice.hadolint.yml @@ -0,0 +1,27 @@ +name: api-bench-history-microservice Hadolint +on: + push: + branches: + - the-one + paths: + - 'containers/api-bench-history-microservice/Dockerfile' + - '.github/workflows/api-bench-history-microservice.hadolint.yml' + pull_request: + branches: + - the-one + paths: + - 'containers/api-bench-history-microservice/Dockerfile' + - '.github/workflows/api-bench-history-microservice.hadolint.yml' +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 360 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - run: sudo apt-get install shellcheck -y + - run: wget https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64 + - run: sudo mv hadolint-Linux-x86_64 /usr/local/bin/hadolint + - run: sudo chmod +x /usr/local/bin/hadolint + - run: hadolint containers/api-bench-history-microservice/Dockerfile diff --git a/.github/workflows/api-bench-history-website.hadolint.yml b/.github/workflows/api-bench-history-website.hadolint.yml new file mode 100644 index 0000000..89038e0 --- /dev/null +++ b/.github/workflows/api-bench-history-website.hadolint.yml @@ -0,0 +1,27 @@ +name: api-bench-history-website Hadolint +on: + push: + branches: + - the-one + paths: + - 'containers/api-bench-history-website/Dockerfile' + - '.github/workflows/api-bench-history-website.hadolint.yml' + pull_request: + branches: + - the-one + paths: + - 'containers/api-bench-history-website/Dockerfile' + - '.github/workflows/api-bench-history-website.hadolint.yml' +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 360 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - run: sudo apt-get install shellcheck -y + - run: wget https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64 + - run: sudo mv hadolint-Linux-x86_64 /usr/local/bin/hadolint + - run: sudo chmod +x /usr/local/bin/hadolint + - run: hadolint containers/api-bench-history-website/Dockerfile diff --git a/.github/workflows/api-bench.hadolint.yml b/.github/workflows/api-bench.hadolint.yml new file mode 100644 index 0000000..0fe7140 --- /dev/null +++ b/.github/workflows/api-bench.hadolint.yml @@ -0,0 +1,27 @@ +name: api-bench Hadolint +on: + push: + branches: + - the-one + paths: + - 'containers/api-bench/Dockerfile' + - '.github/workflows/api-bench.hadolint.yml' + pull_request: + branches: + - the-one + paths: + - 'containers/api-bench/Dockerfile' + - '.github/workflows/api-bench.hadolint.yml' +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 360 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - run: sudo apt-get install shellcheck -y + - run: wget https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64 + - run: sudo mv hadolint-Linux-x86_64 /usr/local/bin/hadolint + - run: sudo chmod +x /usr/local/bin/hadolint + - run: hadolint containers/api-bench/Dockerfile diff --git a/.github/workflows/global.docker.yml b/.github/workflows/global.docker.yml new file mode 100644 index 0000000..b42e84e --- /dev/null +++ b/.github/workflows/global.docker.yml @@ -0,0 +1,52 @@ +name: Docker +on: + push: + branches: + - the-one + paths: + - 'containers/*/Dockerfile' + - '.github/workflows/docker.yml' + pull_request: + branches: + - the-one + paths: + - 'containers/*/Dockerfile' + - '.github/workflows/docker.yml' +jobs: + builder: + name: Builder + runs-on: ubuntu-latest + timeout-minutes: 360 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - run: git fetch --tags + - name: Cache Docker images. + uses: ScribeMD/docker-cache@0.5.0 + with: + key: docker-${{ runner.os }}-${{ hashFiles('containers/api-bench-build/Dockerfile') }} + - run: docker build --build-arg="BUILD_VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)" -t "idrinth/api-bench-build:$(git describe --tags `git rev-list --tags --max-count=1`)" --build-arg="BUILD_TIME=now" containers/api-bench-build + build: + needs: + - builder + strategy: + matrix: + folder: + - 'api-bench-gitlab-runner' + - 'api-bench' + - 'api-bench-gitea-action' + - 'api-bench-history-website' + - 'api-bench-history-microservice' + name: Build ${{ matrix.folder }} + runs-on: ubuntu-latest + timeout-minutes: 360 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - run: git fetch --tags + - name: Cache Docker images. + uses: ScribeMD/docker-cache@0.5.0 + with: + key: docker-${{ runner.os }}-${{ hashFiles('containers/api-bench-build/Dockerfile') }} + read-only: true + - run: docker build --build-arg="BUILD_VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)" --build-arg="BUILD_TIME=now" containers/${{ matrix.folder }} diff --git a/.github/workflows/global.pull-request-size.yml b/.github/workflows/global.pull-request-size.yml new file mode 100644 index 0000000..751b428 --- /dev/null +++ b/.github/workflows/global.pull-request-size.yml @@ -0,0 +1,34 @@ +name: pull request size +on: + pull_request: + branches: + - the-one +env: + CURRENT_NODE_VERSION: ${{ vars.CURRENT_NODE_VERSION || 'latest' }} +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ env.CURRENT_NODE_VERSION }} + uses: actions/setup-node@v4 + with: + node-version: ${{ env.CURRENT_NODE_VERSION }} + cache: 'npm' + cache-dependency-path: | + framework/package-lock.json + documentation-website/package-lock.json + history-microservice/package-lock.json + history-website/package-lock.json + cli/package-lock.json + package-lock.json + - run: npm install -g "https://github.com/Idrinth/check-pr-length.git#patch-1" + - run: git remote add base https://github.com/idrinth/api-bench.git + - run: git config --global user.email "prs@example.com" + - run: git config --global user.name "PRS" + - run: git fetch base the-one + - run: git switch the-one + - run: git remote add pullrequest "https://github.com/${{github.event.pull_request.head.repo.full_name}}" + - run: git fetch pullrequest "${GITHUB_HEAD_REF}" + - run: git switch $GITHUB_HEAD_REF + - run: check-pr-length --max=350 --total=500 --base=the-one --silent=false --exclude="package-lock.json;*/package-lock.json" diff --git a/.github/workflows/global.spellcheck.yml b/.github/workflows/global.spellcheck.yml new file mode 100644 index 0000000..cd3dd49 --- /dev/null +++ b/.github/workflows/global.spellcheck.yml @@ -0,0 +1,41 @@ +name: Spellcheck +on: + push: + branches: + - the-one + paths: + - '**.md' + - 'package-lock.json' + - '.github/workflows/spellcheck.yml' + pull_request: + branches: + - the-one + paths: + - '**.md' + - 'package-lock.json' + - '.github/workflows/spellcheck.yml' +env: + CURRENT_NODE_VERSION: ${{ vars.CURRENT_NODE_VERSION || 'latest' }} +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup Node.js environment ${{ env.CURRENT_NODE_VERSION }} + uses: actions/setup-node@v4 + with: + node-version: ${{ env.CURRENT_NODE_VERSION }} + cache: 'npm' + cache-dependency-path: | + framework/package-lock.json + documentation-website/package-lock.json + history-microservice/package-lock.json + history-website/package-lock.json + cli/package-lock.json + package-lock.json + - name: Build root + run: npm ci + - name: spellcheck + run: npm run spellcheck diff --git a/.github/workflows/root.mdlint.yml b/.github/workflows/root.mdlint.yml new file mode 100644 index 0000000..93518fe --- /dev/null +++ b/.github/workflows/root.mdlint.yml @@ -0,0 +1,41 @@ +name: MARKDOWN-LINT +on: + push: + branches: + - the-one + paths: + - '*.md' + - '.github/**.md' + - 'containers/**.md' + - 'package-lock.json' + - '.github/workflows/root.mdlint.yml' + pull_request: + branches: + - the-one + paths: + - '*.md' + - '.github/**.md' + - 'containers/**.md' + - 'package-lock.json' + - '.github/workflows/root.mdlint.yml' +env: + CURRENT_NODE_VERSION: ${{ vars.CURRENT_NODE_VERSION || 'latest' }} +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ env.CURRENT_NODE_VERSION }} + uses: actions/setup-node@v4 + with: + node-version: ${{ env.CURRENT_NODE_VERSION }} + cache: 'npm' + cache-dependency-path: | + framework/package-lock.json + documentation-website/package-lock.json + history-microservice/package-lock.json + history-website/package-lock.json + cli/package-lock.json + package-lock.json + - run: npm ci + - run: npm run lint-md