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
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ jobs:
- name: Resolve and build package
env:
JULIA_PKG_PRECOMPILE_AUTO: "0"
WENDAO_CODE_PARSER_BOOTSTRAP_ENV: ${{ runner.temp }}/wendaocodeparser-env
run: |
julia --project=. -e 'using Pkg; Pkg.resolve(); Pkg.instantiate(); Pkg.build()'
julia ./scripts/prepare_wendao_code_parser_env.jl
- name: Run package tests
env:
JULIA_NUM_THREADS: ${{ matrix.nthreads }}
JULIA_PKG_PRECOMPILE_AUTO: "0"
WENDAO_CODE_PARSER_BOOTSTRAP_ENV: ${{ runner.temp }}/wendaocodeparser-env
run: |
julia --project=. -e 'using Pkg; Pkg.test("WendaoCodeParser"; coverage=false)'
chmod +x ./scripts/test_wendao_code_parser.sh
./scripts/test_wendao_code_parser.sh
7 changes: 5 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ jobs:
- name: Resolve and build package
env:
JULIA_PKG_PRECOMPILE_AUTO: "0"
WENDAO_CODE_PARSER_BOOTSTRAP_ENV: ${{ runner.temp }}/wendaocodeparser-env
run: |
julia --project=. -e 'using Pkg; Pkg.resolve(); Pkg.instantiate(); Pkg.build()'
julia ./scripts/prepare_wendao_code_parser_env.jl
- name: Run package tests
env:
JULIA_NUM_THREADS: ${{ matrix.nthreads }}
JULIA_PKG_PRECOMPILE_AUTO: "0"
WENDAO_CODE_PARSER_BOOTSTRAP_ENV: ${{ runner.temp }}/wendaocodeparser-env
run: |
julia --project=. -e 'using Pkg; Pkg.test("WendaoCodeParser"; coverage=false)'
chmod +x ./scripts/test_wendao_code_parser.sh
./scripts/test_wendao_code_parser.sh
12 changes: 7 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,31 @@ WendaoArrow = "561c8d8d-4bcf-4807-873b-a6b7d1e55843"

[sources]
Absyn = {rev = "master", url = "https://github.com/OpenModelica/Absyn.jl"}
Arrow = {rev = "2ec9e65ef648c5da4060f0ef8b8e78e7ed00226d", url = "https://github.com/JuliaCN/arrow-julia.git"}
ArrowTypes = {rev = "2ec9e65ef648c5da4060f0ef8b8e78e7ed00226d", subdir = "src/ArrowTypes", url = "https://github.com/JuliaCN/arrow-julia.git"}
Arrow = {rev = "82562ef144a5d8b7d488710cea609fb7488d4efe", url = "https://github.com/JuliaCN/arrow-julia.git"}
ArrowTypes = {rev = "82562ef144a5d8b7d488710cea609fb7488d4efe", subdir = "src/ArrowTypes", url = "https://github.com/JuliaCN/arrow-julia.git"}
gRPCServer = {rev = "261cd70ac0b76c060cef0507245c400da0b5def9", url = "https://github.com/tao3k/gRPCServer.jl"}
ImmutableList = {rev = "master", url = "https://github.com/OpenModelica/ImmutableList.jl"}
JuliaSyntax = {rev = "main", url = "https://github.com/JuliaLang/JuliaSyntax.jl"}
MetaModelica = {rev = "master", url = "https://github.com/OpenModelica/MetaModelica.jl"}
OMParser = {rev = "d59051069e43fb2624aa13fe8935532ca15aecec", url = "https://github.com/tao3k/OMParser.jl"}
PureHTTP2 = {rev = "03d8853e9556a4355d7b650853cda62b1906d88e", url = "https://github.com/s-celles/PureHTTP2.jl"}
WendaoArrow = {rev = "ab02bc080e90a0683978051cc4165b7173c2992b", url = "https://github.com/tao3k/WendaoArrow.jl.git"}
WendaoArrow = {rev = "e992839d84dc92ffc4972e10d160ee4ce53ce126", url = "https://github.com/tao3k/WendaoArrow.jl.git"}

[compat]
Absyn = "1.3"
Arrow = "2.8.1"
ArrowTypes = "2.3.0"
ImmutableList = "0.1"
ImmutableList = "0.1, 0.3"
JuliaSyntax = "2"
MetaModelica = "0.0.5"
MetaModelica = "0.0.5, 0.1"
OMParser = "0.0.3"
PureHTTP2 = "0.5.0"
Tables = "1"
WendaoArrow = "0.1"
julia = "1.12"

[extras]
gRPCServer = "608c6337-0d7d-447f-bb69-0f5674ee3959"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
Expand Down
109 changes: 109 additions & 0 deletions scripts/prepare_wendao_code_parser_env.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import Pkg
using TOML

const SCRIPT_ROOT = @__DIR__
const WENDAO_ROOT = normpath(joinpath(SCRIPT_ROOT, ".."))
const PROJECT_TOML = joinpath(WENDAO_ROOT, "Project.toml")
const BOOTSTRAP_ENV = "WENDAO_CODE_PARSER_BOOTSTRAP_ENV"
const LOCAL_ARROW_ENV = "WENDAO_CODE_PARSER_LOCAL_ARROW_PATH"
const LOCAL_WENDAOARROW_ENV = "WENDAO_CODE_PARSER_LOCAL_WENDAO_ARROW_PATH"

function valid_arrow_checkout(path::AbstractString)
return isfile(joinpath(path, "Project.toml")) &&
isfile(joinpath(path, "src", "ArrowTypes", "Project.toml"))
end

function valid_wendaoarrow_checkout(path::AbstractString)
return isfile(joinpath(path, "Project.toml")) &&
isfile(joinpath(path, "src", "WendaoArrow.jl"))
end

function candidate_arrow_checkouts()
candidates = String[]

if haskey(ENV, LOCAL_ARROW_ENV)
push!(candidates, abspath(ENV[LOCAL_ARROW_ENV]))
end

push!(candidates, normpath(joinpath(dirname(WENDAO_ROOT), "arrow-julia")))

if haskey(ENV, "PRJ_ROOT")
push!(candidates, normpath(joinpath(ENV["PRJ_ROOT"], ".data", "arrow-julia")))
end

return unique(candidates)
end

function candidate_wendaoarrow_checkouts()
candidates = String[]

if haskey(ENV, LOCAL_WENDAOARROW_ENV)
push!(candidates, abspath(ENV[LOCAL_WENDAOARROW_ENV]))
end

push!(candidates, normpath(joinpath(dirname(WENDAO_ROOT), "WendaoArrow.jl")))

if haskey(ENV, "PRJ_ROOT")
push!(candidates, normpath(joinpath(ENV["PRJ_ROOT"], ".data", "WendaoArrow.jl")))
end

return unique(candidates)
end

function maybe_local_checkout(candidates::Vector{String}, validator::Function)
for candidate in candidates
validator(candidate) && return candidate
end
return nothing
end

function remote_source_spec(name::String, entry::Dict{String,Any})
kwargs = Dict{Symbol,Any}(:name => name)
haskey(entry, "url") && (kwargs[:url] = entry["url"])
haskey(entry, "rev") && (kwargs[:rev] = entry["rev"])
haskey(entry, "subdir") && (kwargs[:subdir] = entry["subdir"])
haskey(entry, "path") && (kwargs[:path] = abspath(joinpath(WENDAO_ROOT, entry["path"])))
return Pkg.PackageSpec(; kwargs...)
end

project = TOML.parsefile(PROJECT_TOML)
sources = get(project, "sources", Dict{String,Any}())

env_path = get(ENV, BOOTSTRAP_ENV, mktempdir())
Pkg.activate(env_path)

arrow_checkout = maybe_local_checkout(candidate_arrow_checkouts(), valid_arrow_checkout)
wendaoarrow_checkout =
maybe_local_checkout(candidate_wendaoarrow_checkouts(), valid_wendaoarrow_checkout)

add_specs = Pkg.PackageSpec[]
develop_specs = Pkg.PackageSpec[]

if isnothing(arrow_checkout)
push!(add_specs, remote_source_spec("Arrow", sources["Arrow"]))
push!(add_specs, remote_source_spec("ArrowTypes", sources["ArrowTypes"]))
else
push!(develop_specs, Pkg.PackageSpec(path = arrow_checkout))
push!(develop_specs, Pkg.PackageSpec(path = joinpath(arrow_checkout, "src", "ArrowTypes")))
end

if isnothing(wendaoarrow_checkout)
push!(add_specs, remote_source_spec("WendaoArrow", sources["WendaoArrow"]))
else
push!(develop_specs, Pkg.PackageSpec(path = wendaoarrow_checkout))
end

for (name, entry) in sources
entry isa Dict{String,Any} || continue
name in ("Arrow", "ArrowTypes", "WendaoArrow") && continue
push!(add_specs, remote_source_spec(name, entry))
end

isempty(add_specs) || Pkg.add(add_specs; preserve = Pkg.PRESERVE_DIRECT)
isempty(develop_specs) || Pkg.develop(develop_specs; preserve = Pkg.PRESERVE_DIRECT)
Pkg.develop([Pkg.PackageSpec(path = WENDAO_ROOT)]; preserve = Pkg.PRESERVE_DIRECT)
Pkg.add([Pkg.PackageSpec(name = "Tables")]; preserve = Pkg.PRESERVE_DIRECT)

Pkg.resolve()
Pkg.instantiate()
Pkg.build("WendaoCodeParser")
16 changes: 16 additions & 0 deletions scripts/test_wendao_code_parser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

ENV_PATH="${WENDAO_CODE_PARSER_BOOTSTRAP_ENV:-$(mktemp -d)}"
if [[ -z "${WENDAO_CODE_PARSER_BOOTSTRAP_ENV:-}" ]]; then
trap 'rm -rf "${ENV_PATH}"' EXIT
fi
export WENDAO_CODE_PARSER_BOOTSTRAP_ENV="${ENV_PATH}"

if [[ ! -f "${ENV_PATH}/Project.toml" ]]; then
"${JULIA:-julia}" "${ROOT}/scripts/prepare_wendao_code_parser_env.jl"
fi

exec "${JULIA:-julia}" --project="${ENV_PATH}" "${ROOT}/test/runtests.jl"
Loading