Skip to content

Commit

Permalink
T349803, T369642, T352252, T368382: nx monorepo setup for versioning,…
Browse files Browse the repository at this point in the history
… and CHANGELOG generation (#735)

* Make image builds more atomic
* Add version spec to all images
* Rename build resources to match published image names
* Move typescript setup to root
* fix(wdqs-frontend): FRONTED to FRONTEND typo
* feat(wbs-release): add nvmrc spec for current node LTS ("lts/iron")
* Standardize on node:iron-bullseye tag for node LTS
* Upgrades to latest WDIO v8 minor version
* Removes unnused browserslist from package.json
* Move over to buildx on CI on the way to multi-platform builds
* Makes lint available for individual build projects
* Adds notes on multi-platform builds
  • Loading branch information
lorenjohnson authored Sep 4, 2024
1 parent c837e9b commit 8946bc9
Show file tree
Hide file tree
Showing 144 changed files with 11,014 additions and 14,302 deletions.
23 changes: 23 additions & 0 deletions .eslintrc-whitespace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"root": true,
"parser": "any-eslint-parser",
"ignorePatterns": [
"test/**/results",
"!.github",
"!deploy",
"package-lock.json",
"pnpm/**/**",
"pnpm-lock.yaml",
"*.properties",
"*.ts",
"*.js",
"*.json",
"*.yml",
"*.yaml",
"*.json",
"*.png"
],
"rules": {
"eol-last": [ "error", "always" ]
}
}
64 changes: 64 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"root": true,
"extends": [
"wikimedia/selenium",
"wikimedia/language/es2019",
"@wmde/wikimedia-typescript"
],
"ignorePatterns": [
"**/results/result.json",
"!.github/**/**",
"!deploy",
"package-lock.json",
"pnpm/**/**",
"pnpm-lock.yaml",
"*.properties"
],
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": true,
"ecmaVersion": "latest"
},
"rules": {
"mocha/no-setup-in-describe": "warn",
"node/no-missing-import": "off",
"wdio/no-pause": "warn",
"es-x/no-import-meta": "off",
"es-x/no-nullish-coalescing-operators": "off",
"es-x/no-class-fields": "off",
"no-mixed-spaces-and-tabs": [ "error", "smart-tabs" ],
"eol-last": [ "error", "always" ]
},
"overrides": [
{
"files": [ "*.json" ],
"rules": {
"array-bracket-spacing": "off",
"quotes": "off",
"quote-props": [ "error", "consistent" ],
"@typescript-eslint/semi": "off",
"no-unused-expressions": "off"
}
},
{
"files": [ "*.yaml", "*.yml" ],
"parser": "yaml-eslint-parser",
"rules": {
"max-len": "off",
"spaced-comment": "off",
"yml/block-sequence": 1,
"yml/no-empty-mapping-value": 1,
"yml/plain-scalar": 1
}
},
{
"files": [ "docker-compose*.yaml", "docker-compose*.yml" ],
"parser": "yaml-eslint-parser",
"rules": {
"yml/indent": 1,
"yml/no-empty-mapping-value": "off",
"yml/plain-scalar": "off"
}
}
]
}
4 changes: 2 additions & 2 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

./lint.sh
./nx lint
13 changes: 1 addition & 12 deletions .github/actions/pull-ghcr/action.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
name: pull-ghcr
description: Pull all from GHCR
inputs:
github_token:
description: token to access GHCR
required: true
description: Pull all images from GHCR (for current run ID)

runs:
using: composite

steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ inputs.github_token }}

- shell: bash
run: |
set -x
Expand Down
11 changes: 1 addition & 10 deletions .github/actions/push-ghcr/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,13 @@ name: push-ghcr
description: Push to GHCR
inputs:
docker_image:
description: name of the docker image to push
required: true
github_token:
description: token to access GHCR
description: name of the image to push
required: true

runs:
using: composite

steps:
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ inputs.github_token }}

- shell: bash
run: |
set -x
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/scan-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ runs:
cp ${{ steps.scan.outputs.sarif }} /tmp/sarif-reports/${{ inputs.image_name }}.sarif
- name: Archive scan artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ScanResults
name: dev-${{ github.run_id }}-${{ inputs.image_name }}-image-scan-results
if-no-files-found: error
path: /tmp/sarif-reports/${{ inputs.image_name }}.sarif
42 changes: 42 additions & 0 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "Setup Node and Docker build environment"
description: "Reusable action to set up the environment for builds and tests"
inputs:
github_token:
description: token to access GHCR
required: true

runs:
using: "composite"
steps:
- uses: pnpm/action-setup@v4
with:
version: 9.6.0

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install Javascript dependencies (PNPM)
shell: bash
run: pnpm install

- name: Setup QEMU
uses: docker/setup-qemu-action@v3

- name: Setup a Docker Buildx builder
id: builder
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ inputs.github_token }}

- name: Set NX to run locally using Node vs in Docker dev runner container
shell: bash
run: echo "NX_RUN_LOCAL=true" >> $GITHUB_ENV
1 change: 0 additions & 1 deletion .github/reporter/.gitignore

This file was deleted.

32 changes: 0 additions & 32 deletions .github/reporter/package-lock.json

This file was deleted.

12 changes: 0 additions & 12 deletions .github/reporter/package.json

This file was deleted.

53 changes: 0 additions & 53 deletions .github/reporter/report.js

This file was deleted.

46 changes: 20 additions & 26 deletions .github/workflows/_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Lint
run: ./lint.sh
- uses: ./.github/actions/setup-environment
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- run: ./nx lint

build:
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 60

strategy:
fail-fast: false
matrix:
component:
imageName:
- wikibase
- elasticsearch
- wdqs
Expand All @@ -29,21 +32,14 @@ jobs:

steps:
- uses: actions/checkout@v4

- run: ./build.sh ${{ matrix.component }}

# TODO re-enable as soon as we make use of it
# - name: Scan Image
# uses: ./.github/actions/scan-image
# continue-on-error: true
# with:
# image_name: ${{ matrix.component }}

- uses: ./.github/actions/push-ghcr

- uses: ./.github/actions/setup-environment
with:
docker_image: wikibase/${{ matrix.component }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push ${{ matrix.imageName }}
run: ./nx build ${{ matrix.imageName }} --push

test:
needs: build
runs-on: ubuntu-latest
Expand All @@ -63,28 +59,26 @@ jobs:

steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/pull-ghcr
- uses: ./.github/actions/setup-environment
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- run: ./test.sh ${{ matrix.suite }}
- name: "Pull images from GHCR"
uses: ./.github/actions/pull-ghcr

- name: Reporter
run: |
cd .github/reporter
npm install
node report.js ${{ matrix.suite }}
- name: "Run ${{ matrix.suite }} test suite"
run: ./nx test -- ${{ matrix.suite }}

- name: Show logs
run: |
ls -lahr test/suites/${{ matrix.suite }}/results test/suites/${{ matrix.suite }}/results/*
tail -n +1 test/suites/${{ matrix.suite }}/results/*.log
continue-on-error: true

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: TestResults
name: dev-${{ github.run_id }}-${{ matrix.suite }}-test-results
path: test/suites/**/results

test-success:
Expand Down
Loading

0 comments on commit 8946bc9

Please sign in to comment.