Skip to content

Commit

Permalink
Merge aee4ad2 into c09c3e6
Browse files Browse the repository at this point in the history
  • Loading branch information
outductor authored Aug 19, 2024
2 parents c09c3e6 + aee4ad2 commit 8c2c6df
Show file tree
Hide file tree
Showing 307 changed files with 5,041 additions and 3,232 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/1_18.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: 1.18 build check

on:
push:
branches:
- 1_18
paths:
- src/**
- build.sbt
- .scalafix.conf
- .scalafmt.conf
- project/*
- .github/workflows/**.yml
- .github/actions/**/**.yml

jobs:
build_check:
env:
BUILD_ENVIRONMENT_IS_CI_OR_LOCAL: "CI"
runs-on: ubuntu-22.04
container: ghcr.io/giganticminecraft/seichiassist-builder-v2:1df7cf5
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Prepare build dependencies cache
uses: actions/cache@v4
env:
cache-name: cache-build-dependencies
cache-version: v-5
with:
# sbt等は$HOMEではなくユーザーディレクトリを見ているようで、
# GH Actionsでの ~ は /github/home/ に展開されるにもかかわらず
# 実際のキャッシュは /root/ 以下に配備される。
#
# /root/.ivy/cache, /root/.sbt - sbt関連のキャッシュ
# /root/.m2 - ビルドログを観察した感じprotoc等はここを利用する
# /root/.cache - cousierがscalasbt等をキャッシュするのに使っている
path: |
/root/.ivy2/cache
/root/.sbt
/root/.m2
/root/.cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-${{ github.ref }}-${{ hashFiles('**/build.sbt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-${{ github.ref }}-
${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-
- name: Prepare build cache
if: github.ref != 'refs/heads/master'
uses: actions/cache@v4
env:
cache-name: cache-build
cache-version: v-5
with:
path: |
target
project/target
project/project/target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-${{ github.ref }}-
${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-
# CIでのcheckoutはファイルのタイムスタンプをチェックアウト時刻に設定するため、
# そのままビルドするとlocalDependenciesにあるjarに変更が行われたと見なされ
# 不要なインクリメンタルコンパイルが走る
# タイムスタンプをコミット時刻に設定することでこれが回避できる
- name: Restore localDependencies' timestamps
# 参考: https://qiita.com/tomlla/items/219cea9dd071c8a9e147
run: |
git config --global --add safe.directory /__w/SeichiAssist/SeichiAssist
for jar in localDependencies/*.jar; do
timestamp=`git log -1 --pretty=format:'%cd' --date=format:'%Y%m%d%H%M.%S' $jar`
touch -t "$timestamp" $jar
done
# scalapbは.protoの再コンパイルの必要性を判定する際にタイムスタンプを見ているから、コミット時刻に合わせる
- name: Restore protocol timestamps
## 参考: https://qiita.com/tomlla/items/219cea9dd071c8a9e147
run: |
for proto in protocol/*.proto; do
timestamp=`git log -1 --pretty=format:'%cd' --date=format:'%Y%m%d%H%M.%S' $proto`
touch -t "$timestamp" $proto
done
- name: Check format with Scalafmt
run: ./sbt scalafmtCheckAll

- name: Check lint with Scalafix on push
run: ./sbt "scalafix --check"

- name: Test and build artifact
run: mkdir -p target/build && ./sbt assembly

- name: Clean build artifact for caching target folder
run: rm -r target/build
15 changes: 8 additions & 7 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
branches:
- develop
- master

pull_request:
branches:
- develop
Expand All @@ -15,15 +14,15 @@ jobs:
env:
BUILD_ENVIRONMENT_IS_CI_OR_LOCAL: "CI"
runs-on: ubuntu-22.04
container: ghcr.io/giganticminecraft/seichiassist-builder:1a64049
container: ghcr.io/giganticminecraft/seichiassist-builder-v2:1df7cf5
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Prepare build dependencies cache
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-build-dependencies
cache-version: v-5
Expand All @@ -47,7 +46,7 @@ jobs:
- name: Prepare build cache
if: github.ref != 'refs/heads/master'
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-build
cache-version: v-5
Expand All @@ -68,6 +67,8 @@ jobs:
- name: Restore localDependencies' timestamps
# 参考: https://qiita.com/tomlla/items/219cea9dd071c8a9e147
run: |
git config --global --add safe.directory /__w/SeichiAssist/SeichiAssist
for jar in localDependencies/*.jar; do
timestamp=`git log -1 --pretty=format:'%cd' --date=format:'%Y%m%d%H%M.%S' $jar`
touch -t "$timestamp" $jar
Expand Down Expand Up @@ -102,7 +103,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Test and build artifact
run: sbt assembly
run: mkdir -p target/build && sbt assembly

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand All @@ -125,7 +126,7 @@ jobs:

output-sha:
name: 最終コミットのSHA値を取得する
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
outputs:
sha: ${{ steps.output-sha.outputs.sha }}
steps:
Expand All @@ -140,7 +141,7 @@ jobs:

create_prerelease:
name: GitHub ReleasesにPreReleaseを作成する
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/develop'
needs:
- build_test_and_upload
Expand Down
107 changes: 107 additions & 0 deletions .github/workflows/create_1_18_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Create 1.18 release

on:
pull_request:
paths:
- src/**
- build.sbt
- .scalafix.conf
- .scalafmt.conf
- project/*
- .github/workflows/**.yml
- .github/actions/**/**.yml

jobs:
create_release:
runs-on: ubuntu-22.04
container: ghcr.io/giganticminecraft/seichiassist-builder-v2:1df7cf5
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Prepare build dependencies cache
uses: actions/cache@v4
env:
cache-name: cache-build-dependencies
cache-version: v-5
with:
# sbt等は$HOMEではなくユーザーディレクトリを見ているようで、
# GH Actionsでの ~ は /github/home/ に展開されるにもかかわらず
# 実際のキャッシュは /root/ 以下に配備される。
#
# /root/.ivy/cache, /root/.sbt - sbt関連のキャッシュ
# /root/.m2 - ビルドログを観察した感じprotoc等はここを利用する
# /root/.cache - cousierがscalasbt等をキャッシュするのに使っている
path: |
/root/.ivy2/cache
/root/.sbt
/root/.m2
/root/.cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-${{ github.ref }}-${{ hashFiles('**/build.sbt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-${{ github.ref }}-
${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-
- name: Prepare build cache
if: github.ref != 'refs/heads/master'
uses: actions/cache@v4
env:
cache-name: cache-build
cache-version: v-5
with:
path: |
target
project/target
project/project/target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-${{ github.ref }}-
${{ runner.os }}-build-${{ env.cache-name }}-${{ env.cache-version }}-
# CIでのcheckoutはファイルのタイムスタンプをチェックアウト時刻に設定するため、
# そのままビルドするとlocalDependenciesにあるjarに変更が行われたと見なされ
# 不要なインクリメンタルコンパイルが走る
# タイムスタンプをコミット時刻に設定することでこれが回避できる
- name: Restore localDependencies' timestamps
# 参考: https://qiita.com/tomlla/items/219cea9dd071c8a9e147
run: |
git config --global --add safe.directory /__w/SeichiAssist/SeichiAssist
for jar in localDependencies/*.jar; do
timestamp=`git log -1 --pretty=format:'%cd' --date=format:'%Y%m%d%H%M.%S' $jar`
touch -t "$timestamp" $jar
done
# scalapbは.protoの再コンパイルの必要性を判定する際にタイムスタンプを見ているから、コミット時刻に合わせる
- name: Restore protocol timestamps
## 参考: https://qiita.com/tomlla/items/219cea9dd071c8a9e147
run: |
for proto in protocol/*.proto; do
timestamp=`git log -1 --pretty=format:'%cd' --date=format:'%Y%m%d%H%M.%S' $proto`
touch -t "$timestamp" $proto
done
# sbt-assembly 2以降からディレクトリを作ってくれなくなった
- name: Build artifact
run: mkdir -p target/build && ./sbt assembly

- name: Create and push a tag
id: tag-name
run: |
TAG_NAME=pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}
git tag $TAG_NAME
git push origin $TAG_NAME
echo "value=$TAG_NAME" >> $GITHUB_OUTPUT
- name: Create release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: target/build/SeichiAssist.jar
tag_name: ${{ steps.tag-name.outputs.value }}
draft: false

- name: Clean build artifact for caching target folder
run: rm -r target/build
8 changes: 4 additions & 4 deletions .github/workflows/create_new_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ jobs:
- uses: actions/checkout@master
with:
# これがないとchunk_searchで引っかかってリリースのjarアップロードに失敗する
submodules: 'recursive'
submodules: "recursive"

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
distribution: "temurin"
java-version: "17"

- name: build artifacts
run: sbt assembly
run: mkdir -p target/build && sbt assembly

- name: Create release
id: create_release
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/publish_develop_builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: publish develop build

on:
push:
branches:
- develop

jobs:
publish_build:
runs-on: ubuntu-22.04
steps:
- name: Publish develop build
env:
SEICHIASSIST_DOWNLOADER_TOKEN: ${{ secrets.SEICHIASSIST_DOWNLOADER_TOKEN }}
run: |
curl -s -X 'POST' 'http://localhost/publish/develop' \
-H 'accept: */*' \
-H 'Authorization: Bearer $SEICHIASSIST_DOWNLOADER_TOKEN'
18 changes: 18 additions & 0 deletions .github/workflows/publish_stable_builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: publish stable build

on:
push:
branches:
- master

jobs:
publish_build:
runs-on: ubuntu-22.04
steps:
- name: Publish stable build
env:
SEICHIASSIST_DOWNLOADER_TOKEN: ${{ secrets.SEICHIASSIST_DOWNLOADER_TOKEN }}
run: |
curl -s -X 'POST' 'http://localhost/publish/stable' \
-H 'accept: */*' \
-H 'Authorization: Bearer $SEICHIASSIST_DOWNLOADER_TOKEN'
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

# Local files
deployLocal.sh
localDependencies/spigot-1.12.2.jar
localDependencies/spigot-1.18.2.jar
plugins/*

# Docker
docker/spigot/serverfiles/eula.txt
Expand All @@ -25,3 +26,6 @@ docker/spigot/serverfiles/eula.txt
.metals
project/.bloop/
project/metals.sbt

# scalac に -Yprofile-trace profile.trace を渡しているので、Chrome Trace file が生成される
/profile.trace
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17.0.10
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.4.3
version = 3.8.3
preset=IntelliJ
runner.dialect = scala213

Expand Down
2 changes: 1 addition & 1 deletion CODING_GUIDELINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## \[Scala\] nullを使わない
Scalaのファイルにおいては、`null`を使用する代わりに`Option`を使用してください。

Java (特に、Bukkit/Spigot API) から入ってきた値が`null`になる可能性がある場合は、その呼び出しを早いうちに[`Option(...)`](https://www.scala-lang.org/api/2.13.4/scala/Option$.html#apply[A](x:A):Option[A])で囲い、`Option`にすることが推奨されます。この呼び出しで、引数が`null`だった場合は`None`に、そうでなかった場合は`Some(...)`になります。
Java (特に、Bukkit/Spigot API) から入ってきた値が`null`になる可能性がある場合は、その呼び出しを早いうちに[`Option(...)`](https://www.scala-lang.org/api/2.13.14/scala/Option$.html#apply[A](x:A):Option[A])で囲い、`Option`にすることが推奨されます。この呼び出しで、引数が`null`だった場合は`None`に、そうでなかった場合は`Some(...)`になります。

## \[Scala\] 例外を使わない
例外の代わりに`Either`を使用してください。`Either`を使用すると低コストで合成を行うことができるためです。
Expand Down
Loading

0 comments on commit 8c2c6df

Please sign in to comment.