minosoft ci: cache integration test assets

This commit is contained in:
Moritz Zwerger 2023-11-22 13:31:26 +01:00
parent 901de32766
commit 00e239527f
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
5 changed files with 25 additions and 8 deletions

View File

@ -40,6 +40,12 @@ jobs:
path: ~/.gradle/wrapper path: ~/.gradle/wrapper
key: ${{ matrix.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} key: ${{ matrix.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Setup Gradle Wrapper Cache
uses: actions/cache@v3
with:
path: ./it
key: minosoft-assets
- name: Build - name: Build
uses: gradle/gradle-build-action@v2 uses: gradle/gradle-build-action@v2
with: with:

2
.gitignore vendored
View File

@ -9,3 +9,5 @@ hs_err_pid*.log
# Ignore Gradle build output directory # Ignore Gradle build output directory
build build
it/

View File

@ -29,6 +29,10 @@ cache:
- "gradle/wrapper/gradle-wrapper.properties" - "gradle/wrapper/gradle-wrapper.properties"
paths: paths:
- .gradle_home/wrapper - .gradle_home/wrapper
- key:
"minosoft-assets"
paths:
- ./it
build: build:
stage: build stage: build

View File

@ -38,7 +38,7 @@ internal object MinosoftSIT {
Log.ASYNC_LOGGING = false Log.ASYNC_LOGGING = false
RunConfiguration.VERBOSE_LOGGING = true RunConfiguration.VERBOSE_LOGGING = true
RunConfiguration.APPLICATION_NAME = "Minosoft it" RunConfiguration.APPLICATION_NAME = "Minosoft it"
RunConfiguration::HOME_DIRECTORY.forceSet(Path.of(System.getProperty("java.io.tmpdir"), "minosoft")) RunConfiguration::HOME_DIRECTORY.forceSet(Path.of("./it"))
RunConfiguration::CONFIG_DIRECTORY.forceSet(Path.of(System.getProperty("java.io.tmpdir"), "minosoft").resolve("conf")) RunConfiguration::CONFIG_DIRECTORY.forceSet(Path.of(System.getProperty("java.io.tmpdir"), "minosoft").resolve("conf"))
RunConfiguration.PROFILES_HOT_RELOADING = false RunConfiguration.PROFILES_HOT_RELOADING = false
} }

View File

@ -179,16 +179,20 @@ abstract class StorageProfileManager<P : Profile> : Iterable<P>, Identified {
profile.lock.lock() profile.lock.lock()
storage.updating = true storage.updating = true
unsafeUpdate(profile, data)
storage.updating = false
// storage.invalid = false
profile.lock.unlock()
}
fun unsafeUpdate(profile: P, data: ObjectNode) {
val injectable = InjectableValues.Std() val injectable = InjectableValues.Std()
injectable.addValue(type.clazz, profile) injectable.addValue(type.clazz, profile)
reader reader
.withValueToUpdate(profile) .withValueToUpdate(profile)
.with(injectable) .with(injectable)
.readValue<P>(data) .readValue<P>(data)
storage.updating = false
// storage.invalid = false
profile.lock.unlock()
} }
fun create(name: String): P { fun create(name: String): P {
@ -212,16 +216,17 @@ abstract class StorageProfileManager<P : Profile> : Iterable<P>, Identified {
Log.log(LogMessageType.PROFILES, LogLevels.VERBOSE) { "Saving profile to $path" } Log.log(LogMessageType.PROFILES, LogLevels.VERBOSE) { "Saving profile to $path" }
profile.lock.acquire() profile.lock.acquire()
storage.invalid = false // do it before actually saving it. If the data changes while writing it gets saved another time
storage.saved++ storage.saved++
val node = Jackson.MAPPER.valueToTree<ObjectNode>(profile) // TODO: cache jacksonType val node = Jackson.MAPPER.valueToTree<ObjectNode>(profile) // TODO: cache jacksonType
node.put(VERSION, latestVersion) node.put(VERSION, latestVersion)
val string = Jackson.MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(node) val string = Jackson.MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(node)
val stream = FileOutputStream(path) val stream = FileOutputStream(path)
stream.write(string.encodeNetwork()) stream.write(string.encodeNetwork())
stream.close() stream.close()
storage.invalid = false
profile.lock.release() profile.lock.release()
} }
@ -250,7 +255,7 @@ abstract class StorageProfileManager<P : Profile> : Iterable<P>, Identified {
} }
fun init() { fun init() {
reader reader // init lazy value
} }
companion object { companion object {