Skip to content

refactor(tools): 列参照を位置から列名に変え、統合後の列名に追随させる #11546

refactor(tools): 列参照を位置から列名に変え、統合後の列名に追随させる

refactor(tools): 列参照を位置から列名に変え、統合後の列名に追随させる #11546

Workflow file for this run

# ユニットテスト。
#
# 【設計】本体イメージは「1回だけ」ビルドして GHCR に置き、45個のマトリクス
# ジョブはそれを pull するだけにしている。
#
# - イメージの用意は ci-images.yml (UIテストと共通) に委譲している。
# タグは依存関係ファイルのハッシュで、モジュールのソースは
# requirements-weko-modules.txt により -e (editable) インストールされ、
# docker-compose2.yml が . を /code に bind mount するため、ソース変更で
# イメージを作り直す必要がない。
# → 依存を触らない普通の PR ではビルドが 0 回になる。
# イメージを差し替えたいときの手順は ci-images.yml の先頭を参照。
#
# - install.sh は CI では使わない。ユニットテストは conftest.py が自前で
# wekotest DB を作り、instance_path も tempfile.mkdtemp() を使うので、
# populate-instance / デモSQL / invenio assets build / invenio collect と
# nginx・pgpool・worker・inbox・mongo・flower の起動はいずれも不要。
# 起動するのは PostgreSQL / Elasticsearch / Redis / RabbitMQ の4つだけ。
#
# - tox が毎回 requirements2.txt (約290パッケージ) を入れ直す分は、
# bind mount 済みの .ci-cache/pip を pip のキャッシュにして共有する。
#
# fork からの PR は GHCR に push できない。その場合はビルドキャッシュ
# (type=gha) だけ作り、各ジョブがそこからローカルビルドする。
name: Unit Tests
on:
push:
pull_request:
workflow_dispatch:
inputs:
force_rebuild:
description: CI イメージを作り直す(依存を変えずに差し替えたいとき)
type: boolean
default: false
jobs:
images:
uses: ./.github/workflows/ci-images.yml
permissions:
contents: read
packages: write
with:
force_rebuild: ${{ inputs.force_rebuild || false }}
test:
name: ${{ matrix.module }}
needs: images
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: read
packages: read
env:
COMPOSE_FILE: docker-compose2.yml:docker-compose.ci.yml
WEKO_IMAGE: ${{ needs.images.outputs.web }}
WEKO_ES_IMAGE: ${{ needs.images.outputs.es }}
WEKO_NGINX_IMAGE: ${{ needs.images.outputs.nginx }}
strategy:
fail-fast: false
max-parallel: 4
matrix:
module:
- invenio-accounts
- invenio-communities
- invenio-db
- invenio-deposit
- invenio-files-rest
- invenio-iiif
- invenio-indexer
- invenio-mail
- invenio-oaiharvester
- invenio-oaiserver
- invenio-oauth2server
- invenio-previewer
- invenio-queues
- invenio-records-rest
- invenio-records
- invenio-resourcesyncclient
- invenio-resourcesyncserver
- invenio-s3
- invenio-stats
- weko-accounts
- weko-admin
- weko-authors
- weko-bulkupdate
- weko-deposit
- weko-gridlayout
- weko-groups
- weko-handle
- weko-index-tree
- weko-indextree-journal
- weko-items-autofill
- weko-items-ui
- weko-itemtypes-ui
- weko-logging
- weko-plugins
- weko-records-ui
- weko-records
- weko-redis
- weko-schema-ui
- weko-search-ui
- weko-sitemap
- weko-swordserver
- weko-theme
- weko-user-profiles
- weko-workflow
steps:
- name: Checkout code
uses: actions/checkout@v4
# テストはコンテナ内で動くので、ランナー側の Python は不要。
# フォントは描画系のテストが参照する。
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y fonts-noto-cjk fonts-noto-color-emoji
- name: Log in to GHCR
continue-on-error: true
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull prebuilt images
id: pull
continue-on-error: true
run: |
docker pull -q "$WEKO_IMAGE"
docker pull -q "$WEKO_ES_IMAGE"
# fork PR など pull できない場合のみ、ビルドキャッシュからローカルビルドする。
- name: Set up Docker Buildx
if: steps.pull.outcome == 'failure'
uses: docker/setup-buildx-action@v3
- name: Build WEKO image (fallback)
if: steps.pull.outcome == 'failure'
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
tags: ${{ env.WEKO_IMAGE }}
load: true
cache-from: type=gha,scope=weko-web
- name: Build Elasticsearch image (fallback)
if: steps.pull.outcome == 'failure'
uses: docker/build-push-action@v6
with:
context: .
file: elasticsearch/Dockerfile
tags: ${{ env.WEKO_ES_IMAGE }}
load: true
cache-from: type=gha,scope=weko-es
# tox が張る venv への pip インストールを、ダウンロードなしで済ませる。
# .ci-cache は bind mount 経由でコンテナから /code/.ci-cache として見える。
- name: Restore pip cache
uses: actions/cache/restore@v4
with:
path: .ci-cache/pip
key: weko-pip-${{ hashFiles('modules/*/requirements2.txt') }}
restore-keys: |
weko-pip-
- name: Prepare workspace permissions
# コンテナは uid 1000 (invenio) で動く。bind mount 先を書けるようにする。
run: |
mkdir -p .ci-cache/pip
sudo chown -R 1000:1000 ./modules .ci-cache
# ユニットテストが使うのはこの4つだけ。
# nginx・pgpool・worker・inbox・mongo・flower は起動しない。
- name: Start test services
run: docker compose up -d --quiet-pull postgresql elasticsearch redis rabbitmq
- name: Wait for services to be ready
run: bash scripts/ci/wait-for-services.sh
- name: Run tox in ${{ matrix.module }}
run: |
docker compose run --rm --no-deps -T \
web bash /code/scripts/ci/run-module-tests.sh '${{ matrix.module }}'
- name: Show logs if failed
if: failure()
run: docker compose logs --tail=200
# pip の http キャッシュは 0600 で作られるため、uid 1000 のままだと
# ランナー(uid 1001)が tar で読めず保存に失敗する。所有権を戻す。
- name: Restore cache ownership
if: always()
run: |
[ -d .ci-cache ] || exit 0
sudo chown -R "$(id -u):$(id -g)" .ci-cache
# 45ジョブが同じキーで保存を試みるが、先着1つだけが保存され残りは
# 予約に失敗してスキップされる(警告のみ)。モジュール間で
# requirements2.txt はほぼ同一なので、1つ保存されれば全体に効く。
- name: Save pip cache
if: always()
continue-on-error: true
uses: actions/cache/save@v4
with:
path: .ci-cache/pip
key: weko-pip-${{ hashFiles('modules/*/requirements2.txt') }}
- name: Stop containers
if: always()
run: docker compose down -v