Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# NOTE: do not add .git here. The Dockerfile's `versioner` stage runs
# `git describe` against it to stamp the build version (issue #1014); excluding
# it makes every build report "unknown".
docs
documentMD
*/node_modules
Expand Down
29 changes: 18 additions & 11 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,23 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: eWaterCycle/setup-apptainer@v2
- name: stamp version.json for this build
# master is branch-protected (rejects direct pushes even from Actions bots),
# so this can't be committed back - it only needs to be baked into the
# artifacts built below, which the Dockerfile's `COPY server server` picks up
# from this worktree.
- name: determine version number for this build
# This value is baked into the image via the WHEEL_VERSION build-arg (see
# the docker build step) and into source.tar.gz below. It is never
# committed back: master is branch-protected, and the per-branch
# `[skip ci] update version number` commits used to conflict on
# server/app/db/version.json between parallel PRs (issue #1014).
run: |
case "${BRANCH_NAME}" in
master) TYPE=release ;;
maintenance*) TYPE=maintenance ;;
*) TYPE=beta ;;
esac
VERSION_NUMBER="$(date '+%Y-%m%d-%H%M%S')-${TYPE}"
echo "{\"version\": \"${VERSION_NUMBER}\" }" > server/app/db/version.json
cat server/app/db/version.json
echo "VERSION_NUMBER=${VERSION_NUMBER}" >>$GITHUB_ENV
echo "VERSION_NUMBER=$(date '+%Y-%m%d-%H%M%S')-${TYPE}" >>$GITHUB_ENV
# only master builds (TYPE=release) own the `latest` docker tag and the
# GitHub "Latest" release; maintenance*/beta builds must not.
echo "RELEASE_TYPE=${TYPE}" >>$GITHUB_ENV
- run: docker build -t ${DOCKER_USER_NAME}/${DOCKER_CONTAINER_NAME}:${BRANCH_NAME} .
- run: docker build --build-arg WHEEL_VERSION="${VERSION_NUMBER}" -t ${DOCKER_USER_NAME}/${DOCKER_CONTAINER_NAME}:${BRANCH_NAME} .
- run: docker login -u ${DOCKER_USER_NAME} -p ${DOCKER_PASSWORD}
- run: docker push ${DOCKER_USER_NAME}/${DOCKER_CONTAINER_NAME}:${BRANCH_NAME}
- name: publish :latest for mainline releases only
Expand All @@ -41,7 +39,16 @@ jobs:
docker push ${DOCKER_USER_NAME}/${DOCKER_CONTAINER_NAME}:latest
- run: docker save ${DOCKER_USER_NAME}/${DOCKER_CONTAINER_NAME}:${BRANCH_NAME} | gzip > wheel_docker.tar.gz
- run: apptainer build wheel.sif docker-daemon://${DOCKER_USER_NAME}/${DOCKER_CONTAINER_NAME}:${BRANCH_NAME}
- run: git archive --format=tar.gz --prefix=OpenWHEEL-${BRANCH_NAME}/ -o source.tar.gz HEAD
- name: pack source.tar.gz with the version baked in
# git archive would ship the committed placeholder version.json; extract
# the tracked tree, drop in the real version, and re-pack so a run from
# source.tar.gz reports the same version as the images (issue #1014).
run: |
rm -rf _src && mkdir -p _src
git archive --prefix=OpenWHEEL-${BRANCH_NAME}/ HEAD | tar -x -C _src
echo "{\"version\": \"${VERSION_NUMBER}\" }" > _src/OpenWHEEL-${BRANCH_NAME}/server/app/db/version.json
tar -czf source.tar.gz -C _src OpenWHEEL-${BRANCH_NAME}
rm -rf _src
- name: create release and upload artifact
uses: softprops/action-gh-release@v2
with:
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/run_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
WHEEL_TEST_REMOTEHOST: testServer
WHEEL_TEST_REMOTE_PASSWORD: passw0rd
TZ: JST-9
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -53,31 +52,6 @@ jobs:
working-directory: ./server
- run: npm run test
working-directory: ./server
- name: determine release type from branch name
run: |
case "${{ github.ref_name }}" in
master) TYPE=release ;;
maintenance*) TYPE=maintenance ;;
*) TYPE=beta ;;
esac
echo "VERSION_NUMBER=$(date '+%Y-%m%d-%H%M%S')-${TYPE}" >>$GITHUB_ENV
- run: cat server/app/db/version.json
- name: update version.json
id: create-json
uses: jsdaniell/create-json@v1.2.2
with:
dir: "server/app/db"
name: "version.json"
json: '{"version": "${{ env.VERSION_NUMBER }}" }'
- run: cat server/app/db/version.json
- name: commit and push version.json
run: |
git remote set-url origin https://github-actions:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}
git config user.name 'version-number-updater[bot]'
git config user.email 'action@github.com'
git add server/app/db/version.json
git commit -m '[skip ci] update version number'
git push origin HEAD:${GITHUB_REF}
backup:
needs: ["test"]
runs-on: ubuntu-latest
Expand Down
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ RUN apt-get update && apt -y install curl git rsync openssh-server &&\
COPY --from=builder /usr/src/server /usr/src/server
RUN rm -fr server/app/config/*

# Resolve one version string for this build from the .git in the build context.
# This happens at build time so the value is frozen into the image (static, not
# recomputed at server start). Everything in this stage is discarded except
# /wheel-version - the copied .git never reaches the final image. See issue #1014.
# (Do not add .git to .dockerignore or every build falls back to "unknown".)
# No --dirty: git describe would inspect the working tree, but .dockerignore
# hides tracked paths (documentMD/ etc.) from `COPY . .`, so --dirty would always
# fire. The abbreviated commit is enough to identify the source.
FROM base AS versioner
COPY . .
RUN git describe --tags --always --long --abbrev=12 > /wheel-version 2>/dev/null \
|| echo unknown > /wheel-version

# run UT
FROM base as UT
WORKDIR /usr/src/server
Expand All @@ -33,6 +46,18 @@ CMD ["npm", "run", "coverage"]
FROM base as exec
WORKDIR /usr/src/server

# bake the build version (issue #1014):
# - WHEEL_VERSION build-arg wins (CI passes the release/beta string)
# - else the git-derived value from the versioner stage, marked -local
# - else leave version.json as shipped (committed placeholder, or a
# source.tar.gz that already carries a baked version)
COPY --from=versioner /wheel-version /tmp/wheel-version
ARG WHEEL_VERSION=
RUN if [ -n "${WHEEL_VERSION}" ]; then \
printf '{"version": "%s" }\n' "${WHEEL_VERSION}" > app/db/version.json ; \
elif [ "$(cat /tmp/wheel-version)" != unknown ]; then \
printf '{"version": "%s-local" }\n' "$(cat /tmp/wheel-version)" > app/db/version.json ; \
fi
COPY --from=builder /usr/src/server/app/public /usr/src/server/app/public
COPY entrypoint.sh /usr/src/server/
RUN rm -fr server/app/config/* server/test/
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,3 @@ Any other markdown files under documentMD is detailed informatin for developpers
> cd server
> npm start
```

### CI/CD process
when you push new commit to github, server/app/db/version.json will be updated during CI/CD process.
So, you have to pull before make further commit.
32 changes: 32 additions & 0 deletions documentMD/design/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,38 @@ saveボタンの押下 | git commit
revertボタンの押下 | git reset HEAD --hard
cleanボタンの押下 | rm -fr && git reset HEAD --hard

## バージョン番号の管理
サーバ起動時のログ(`starting WHEEL server (version X)`)とログ画面の「about」で
表示するバージョン番号は、`server/app/core/versionInfo.js` が
`server/app/db/version.json` の `version` を読んで使っているだけである。

リポジトリに commit されている値は固定のプレースホルダで、CI を含め誰もこの
ファイルを書き換えない。

```json
{"version": "not defined - this is a development build"}
```

(過去は `run_test.yml` が push のたびに日付ベースの値を各ブランチへ
commit-back していたが、並行して出している複数の PR が `version.json` で
必ず conflict するのと、merge のたびに stale な値が main / maintenance に
乗ってしまう問題があったため廃止した。GitLab issue `aicshud/WHEEL#1014`。)

実際に表示される文字列は、実行経路ごとに **ビルド時** に焼き込まれる。
アプリのコードが起動時にバージョンを計算することはない。

| 実行経路 | version.json を書くのは | 表示される文字列 |
|---|---|---|
| 公式リリース(`build_and_deploy.yml`) | CI が `docker build --build-arg WHEEL_VERSION=...` で渡す | `YYYY-MMDD-HHMMSS-{release\|maintenance\|beta}`(GitHub Release のタグと一致) |
| `docker build .`(`.git` あり・build-arg なし) | Dockerfile の `versioner` ステージが `git describe` した値 | `<git describe>-local` |
| `docker build --build-arg WHEEL_VERSION=... .` | Dockerfile(build-arg 優先) | 渡した値そのまま |
| `source.tar.gz` を展開して build | CI が焼き込んだ値を保持 | `YYYY-MMDD-HHMMSS-{type}` |
| ソースから直接 `npm start`(ビルドなし) | 誰も書かない(プレースホルダのまま) | `not defined - this is a development build` |
| `compose.dev.yml` での開発 | 上記と同じ(`server/app` を bind mount するため、イメージに焼き込まれた値は隠れる) | `not defined - this is a development build` |

`server/app/db/version.json` は手で書き換えない。中身はビルド処理が焼き込む
ものであり、リポジトリ上の値は「ビルドされていない」ことを示すプレースホルダ
として固定してある。

## 画面遷移
![画面遷移図](./screen_transition.svg)
Expand Down
2 changes: 1 addition & 1 deletion server/app/db/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version": "2026-0903-093647-maintenance" }
{"version": "not defined - this is a development build"}
Loading