test CI run

This commit is contained in:
neuecc 2023-04-16 01:27:25 +09:00
parent 4160525415
commit b98313b74f
3 changed files with 153 additions and 13 deletions

View File

@ -16,6 +16,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: cargo build --verbose
- run: cargo test update_package_version -- 1.0.0 --nocapture
build-dotnet:
runs-on: ubuntu-latest
timeout-minutes: 10

105
.github/workflows/build-release.yml vendored Normal file
View File

@ -0,0 +1,105 @@
name: Build-Release
on:
workflow_dispatch:
inputs:
tag:
description: "tag: git tag you want create. (sample 1.0.0)"
required: true
dry-run:
description: "dry-run: false = create release/nuget. true = never create release/nuget."
required: true
default: false
type: boolean
jobs:
update-packagejson:
uses: Cysharp/Actions/.github/workflows/update-packagejson.yaml@main
with:
file-path: ./src/MemoryPack.Unity/Assets/Plugins/MemoryPack/package.json
tag: ${{ inputs.tag }}
dry-run: ${{ inputs.dry-run }}
push-tag: false
build-dotnet:
needs: [update-packagejson]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- run: echo ${{ needs.update-packagejson.outputs.sha }}
- uses: actions/checkout@v3
with:
ref: ${{ needs.update-packagejson.outputs.sha }}
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
with:
dotnet-version: |
6.0.x
7.0.x
# pack nuget
- run: dotnet build -c Release -p:Version=${{ inputs.tag }}
- run: dotnet test -c Release --no-build
- run: dotnet pack -c Release --no-build -p:Version=${{ inputs.tag }} -o ./publish
- uses: actions/upload-artifact@v3
with:
name: nuget
path: ./publish
build-unity:
needs: [update-packagejson]
strategy:
matrix:
unity: ["2021.3.11f1"]
include:
- unity: 2021.3.11f1
license: UNITY_LICENSE_2021
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- run: echo ${{ needs.update-packagejson.outputs.sha }}
- uses: actions/checkout@v3
with:
ref: ${{ needs.update-packagejson.outputs.sha }}
# Execute scripts: Export Package
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export
- name: Export unitypackage
uses: game-ci/unity-builder@v2
env:
UNITY_LICENSE: ${{ secrets[matrix.license] }}
with:
projectPath: src/MemoryPack.Unity
unityVersion: ${{ matrix.unity }}
targetPlatform: StandaloneLinux64
buildMethod: PackageExporter.Export
versioning: None
# check meta files
- uses: Cysharp/Actions/.github/actions/check-metas@main
with:
directory: src/MemoryPack.Unity
# Store artifacts.
- uses: actions/upload-artifact@v3
with:
name: MemoryPack.${{ inputs.tag }}.unitypackage
path: ./src/MemoryPack.Unity/MemoryPack.${{ inputs.tag }}.unitypackage
if-no-files-found: error
# release
create-release:
needs: [update-packagejson, build-dotnet, build-unity]
uses: Cysharp/Actions/.github/workflows/create-release.yaml@main
with:
dry-run: ${{ inputs.dry-run }}
commit-id: ${{ needs.update-packagejson.outputs.sha }}
tag: ${{ inputs.tag }}
push-tag: true
nuget-push: true
unitypackage-upload: true
unitypackage-name: MemoryPack.${{ inputs.tag }}.unitypackage
unitypackage-path: ./MemoryPack.${{ inputs.tag }}.unitypackage/MemoryPack.${{ inputs.tag }}.unitypackage
secrets: inherit
cleanup:
if: needs.update-packagejson.outputs.is-branch-created == 'true'
needs: [update-packagejson, create-release]
uses: Cysharp/Actions/.github/workflows/clean-packagejson-branch.yaml@main
with:
branch: ${{ needs.update-packagejson.outputs.branch-name }}

View File

@ -136,6 +136,15 @@ fn collect_field_types(
}
}
#[cfg(test)]
mod tests {
use std::{
env,
fs::{self},
};
use super::*;
#[test]
fn test() {
let path = std::env::current_dir().unwrap();
@ -151,3 +160,28 @@ fn test() {
)
.unwrap();
}
// cargo test update_package_version -- 1.0.0 --nocapture
#[test]
fn update_package_version() {
let args: Vec<String> = env::args().collect();
// 0: exe path
// 1: update_package_version
// 2: 1.0.0
// 3: --nocapture
if args[1] != "update_package_version" {
return;
}
println!("version: {}", args[2]);
let mut path = std::env::current_dir().unwrap();
println!("current_dir: {}", path.display());
path.push("Cargo.toml");
let toml = fs::read_to_string(path).unwrap();
println!("current toml: {}", toml);
}
}