diff --git a/.github/test.yml b/.github/test.yml new file mode 100644 index 0000000..ec86cc8 --- /dev/null +++ b/.github/test.yml @@ -0,0 +1,27 @@ +name: test +on: + push: + branches: [master, develop] + pull_request: + types: [opened, synchronize, reopened] +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} +jobs: + test-windows: + name: Test Windows + runs-on: self-hosted + steps: + - name: Initialize instance + run: | + Remove-Item -Path '${{ github.workspace }}\*' -Force -Recurse + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Test + run: | + .\test\test.bat \ No newline at end of file diff --git a/.gitignore b/.gitignore index c76be27..a141167 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,8 @@ docs/site/ # environment. Manifest.toml format/Manifest.toml -revise/Manifest.toml \ No newline at end of file +revise/Manifest.toml + +test/Example.jl/compile/build/ +test/Example.jl/compile/Example.log +test/Example.jl/compile/build.ok diff --git a/Project.toml b/Project.toml index d2cd76c..1e7c368 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "PSRContinuousDeployment" uuid = "f0087d4c-ff99-426e-93c9-09c1a88911f9" -version = "0.7.2" +version = "0.8.0" [deps] AWS = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc" diff --git a/src/compile.jl b/src/compile.jl index ed30410..a7b82b4 100644 --- a/src/compile.jl +++ b/src/compile.jl @@ -12,6 +12,7 @@ function compile( filter_stdlibs::Bool = true, include_lazy_artifacts::Bool = true, include_transitive_dependencies::Bool = true, + skip_version_jl::Bool = false, kwargs..., ) target = configuration.target @@ -36,39 +37,44 @@ function compile( Log.info("COMPILE: Creating build directory") mkdir(build_path) - Log.info("COMPILE: Creating version.jl") - sha1 = read_git_sha1(package_path) - date = read_git_date(package_path) - build_date = Dates.format(Dates.now(Dates.UTC), dateformat"yyyy-mm-dd HH:MM:SS -0000") - write_version_jl(src_path, sha1, date, version, build_date) - - free_memory = round(Int, Sys.free_memory() / 2^20) - total_memory = round(Int, Sys.total_memory() / 2^20) - Log.info("COMPILE: memory free $free_memory MB") - Log.info("COMPILE: memory total $total_memory MB") - - PackageCompiler.create_app( - package_path, - build_path, - executables = executables, - precompile_execution_file = precompile_path, - incremental = false, - filter_stdlibs = filter_stdlibs, - force = true, - include_lazy_artifacts = include_lazy_artifacts, - include_transitive_dependencies = include_transitive_dependencies, - kwargs..., - ) - - Log.info("COMPILE: Cleaning version.jl") - clean_version_jl(src_path) - - Log.info("COMPILE: Creating $target.ver") - open(joinpath(bin_path, "$target.ver"), "w") do io - writeln(io, sha1) - return nothing + if !skip_version_jl + Log.info("COMPILE: Creating version.jl") + sha1 = read_git_sha1(package_path) + date = read_git_date(package_path) + build_date = Dates.format(Dates.now(Dates.UTC), dateformat"yyyy-mm-dd HH:MM:SS -0000") + write_version_jl(src_path, sha1, date, version, build_date) + + free_memory = round(Int, Sys.free_memory() / 2^20) + total_memory = round(Int, Sys.total_memory() / 2^20) + Log.info("COMPILE: memory free $free_memory MB") + Log.info("COMPILE: memory total $total_memory MB") end + PackageCompiler.create_app( + package_path, + build_path, + executables = executables, + precompile_execution_file = precompile_path, + incremental = false, + filter_stdlibs = filter_stdlibs, + force = true, + include_lazy_artifacts = include_lazy_artifacts, + include_transitive_dependencies = include_transitive_dependencies, + sysimage_build_args = `--strip-metadata --strip-ir`, + kwargs..., + ) + if !skip_version_jl + + Log.info("COMPILE: Cleaning version.jl") + clean_version_jl(src_path) + + Log.info("COMPILE: Creating $target.ver") + open(joinpath(bin_path, "$target.ver"), "w") do io + writeln(io, sha1) + return nothing + end + end + Log.info("COMPILE: Copying additional files") for file_path in additional_files_path copy(dirname(file_path), bin_path, basename(file_path)) @@ -87,7 +93,14 @@ function compile( end Log.info("COMPILE: Copying Project.toml") - copy(configuration.package_path, bin_path, "Project.toml") + + open(joinpath(bin_path, "Project.toml"), "w") do io + writeln(io, "name = \"$target\"") + writeln(io, "version = \"$version\"") + end + + Log.info("COMPILE: Removing julia.exe") + rm(joinpath(bin_path, "julia.exe"), force = true) Log.info("COMPILE: Success") touch(joinpath(compile_path, "build.ok")) diff --git a/test/Example.jl/Example.bat b/test/Example.jl/Example.bat new file mode 100644 index 0000000..e9653c1 --- /dev/null +++ b/test/Example.jl/Example.bat @@ -0,0 +1,5 @@ +@echo off + +SET BASEPATH=%~dp0 + +CALL "%JULIA_194%" --project=%BASEPATH% %BASEPATH%\main.jl %* \ No newline at end of file diff --git a/test/Example.jl/Project.toml b/test/Example.jl/Project.toml new file mode 100644 index 0000000..3d930e3 --- /dev/null +++ b/test/Example.jl/Project.toml @@ -0,0 +1,11 @@ +name = "Example" +uuid = "28d347f4-7536-4c5e-b41f-4013aab74eac" +version = "0.1.0" + +[deps] + +[extras] +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets] +test = ["Test"] diff --git a/test/Example.jl/compile/precompile.jl b/test/Example.jl/compile/precompile.jl new file mode 100644 index 0000000..4954e58 --- /dev/null +++ b/test/Example.jl/compile/precompile.jl @@ -0,0 +1,5 @@ +import Pkg +Pkg.activate(@__DIR__) +Pkg.instantiate() + +using Example diff --git a/test/Example.jl/database/migrations/1/down.sql b/test/Example.jl/database/migrations/1/down.sql new file mode 100644 index 0000000..0b0480d --- /dev/null +++ b/test/Example.jl/database/migrations/1/down.sql @@ -0,0 +1 @@ +PRAGMA user_version = 0; \ No newline at end of file diff --git a/test/Example.jl/database/migrations/1/up.sql b/test/Example.jl/database/migrations/1/up.sql new file mode 100644 index 0000000..b7434db --- /dev/null +++ b/test/Example.jl/database/migrations/1/up.sql @@ -0,0 +1,2 @@ +PRAGMA foreign_keys = ON; +PRAGMA user_version = 1; diff --git a/test/Example.jl/database/ui/main.toml b/test/Example.jl/database/ui/main.toml new file mode 100644 index 0000000..054ccfc --- /dev/null +++ b/test/Example.jl/database/ui/main.toml @@ -0,0 +1,4 @@ +model = "Example" +extension = "example" +executable = "Example.bat" +collections = [] \ No newline at end of file diff --git a/test/Example.jl/main.jl b/test/Example.jl/main.jl new file mode 100644 index 0000000..ab195e0 --- /dev/null +++ b/test/Example.jl/main.jl @@ -0,0 +1,6 @@ +import Pkg +Pkg.instantiate() + +using Example + +Example.main(ARGS); diff --git a/test/Example.jl/src/Example.jl b/test/Example.jl/src/Example.jl new file mode 100644 index 0000000..3256157 --- /dev/null +++ b/test/Example.jl/src/Example.jl @@ -0,0 +1,5 @@ +module Example + +include("main.jl") + +end diff --git a/test/Example.jl/src/main.jl b/test/Example.jl/src/main.jl new file mode 100644 index 0000000..50313eb --- /dev/null +++ b/test/Example.jl/src/main.jl @@ -0,0 +1,11 @@ +function main(args::Vector{String}) + + println("Example.jl") + + return nothing +end + +function julia_main()::Cint + main(ARGS) + return 0 +end diff --git a/test/Example.jl/src/version.jl b/test/Example.jl/src/version.jl new file mode 100644 index 0000000..2b9d839 --- /dev/null +++ b/test/Example.jl/src/version.jl @@ -0,0 +1,4 @@ +const GIT_SHA1 = "xxxxxxx" +const GIT_DATE = "xxxx-xx-xx xx:xx:xx -xxxx" +const PKG_VERSION = "x.x.x" +const PKG_BUILD_DATE = "xxxx-xx-xx xx:xx:xx -xxxx" diff --git a/test/Example.jl/test/runtests.jl b/test/Example.jl/test/runtests.jl new file mode 100644 index 0000000..644ec41 --- /dev/null +++ b/test/Example.jl/test/runtests.jl @@ -0,0 +1 @@ +using Test \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 664ada6..4ccc44d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,14 +5,26 @@ using Test const ID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" function testall() - package_path = raw"D:\development\psrnetwork\PSRNetworkReport.jl" + package_path = joinpath(@__DIR__, "Example.jl") + database_path = joinpath(package_path, "database") - configuration = PSRContinuousDeployment.Configuration(package_path) + configuration = PSRContinuousDeployment.Configuration( + package_path, + development_stage = PSRContinuousDeployment.DevelopmentStage.Alpha, + ) - # PSRContinuousDeployment.compile(configuration) - PSRContinuousDeployment.create_setup(configuration, ID, sign = false) + PSRContinuousDeployment.compile( + configuration, + additional_files_path = [ + database_path, + ], + windows_additional_files_path = [ + joinpath(package_path, "Example.bat"), + ], + skip_version_jl = true, + ) - return nothing + return 0 end -testall() +testall() \ No newline at end of file