diff --git a/.github/workflows/julia-tests.yaml b/.github/workflows/julia-tests.yaml new file mode 100644 index 0000000..8149589 --- /dev/null +++ b/.github/workflows/julia-tests.yaml @@ -0,0 +1,28 @@ +--- +# Julia Tests + +name: Correctness - Julia +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: 1 + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-runtest@v1 + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: lcov.info + - uses: actions/upload-artifact@v3 + with: + name: payloads + path: test/logs/ \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..7667dfe --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,57 @@ +--- +# Automatically build Docker images on changes to main and push them to a +# Container Registry using HCL Bake file. + +name: Build Docker Images +# yamllint disable-line rule:truthy +on: + workflow_dispatch: + push: + branches: ['main'] + tags: ['*'] + +jobs: + # Call the Lint & Format workflow before publishing + verify: + uses: ./.github/workflows/lint.yaml + + # Generate a more robust tag for the image + tag-generator: + name: Determine image tag + runs-on: ubuntu-22.04 + outputs: + image-tag: ${{ steps.generate.outputs.tag }} + steps: + - name: Generate appropriate tag + id: generate + run: | + if [[ '${{ github.ref_type }}' == 'branch' && '${{ github.ref_name }}' == 'main' ]]; then + TAG=latest + else + SEMVER=$( echo ${{ github.ref_name }} | sed -nre 's/^v[^0-9]*(([0-9]+\.)*[0-9]+(-[a-z]+)?).*/\1/p') + if [[ -n $SEMVER ]]; then + TAG=${SEMVER} + else + TAG=${{ github.ref_name }} + fi + fi + echo "$TAG" + echo "tag=${TAG,,}" >> ${GITHUB_OUTPUT} + - name: Show Generated Tag + run: echo ${{ steps.generate.outputs.tag }} + + # Build and Publish all targets associated with specified group + bake: + needs: + - verify + - tag-generator + uses: darpa-askem/.github/.github/workflows/bake-publish.yml@main + with: + file: 'docker/docker-bake.hcl' + group: 'prod' + registry: 'ghcr.io' + organization: ${{ github.repository_owner }} + tag: ${{ needs.tag-generator.outputs.image-tag }} + secrets: + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index cba0f80..42afd83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +### Python ### + # Eclipse .project .classpath @@ -33,5 +35,9 @@ api.env # Minio .minio.sys +### Julia ### +test/logs/ + +### Project ### # Config config.env diff --git a/Manifest.toml b/Manifest.toml index 93df486..7619281 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -2,7 +2,7 @@ julia_version = "1.8.5" manifest_format = "2.0" -project_hash = "7c273371f028a1fde3fe326deca65beb41affbb7" +project_hash = "cccb141b5a2246189eea16445310ddc452bd40b4" [[deps.AbstractAlgebra]] deps = ["GroupsCore", "InteractiveUtils", "LinearAlgebra", "MacroTools", "Markdown", "Random", "RandomExtensions", "SparseArrays", "Test"] diff --git a/Project.toml b/Project.toml index 10061c8..a682826 100644 --- a/Project.toml +++ b/Project.toml @@ -26,3 +26,4 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5" Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/config.env.sample b/config.env.sample deleted file mode 100644 index 230526d..0000000 --- a/config.env.sample +++ /dev/null @@ -1,3 +0,0 @@ -AWS_ACCESS_KEY_ID=miniouser -AWS_SECRET_ACCESS_KEY=miniopass -STORAGE_HOST=s3://sims/ diff --git a/docker/docker-back.hcl b/docker/docker-back.hcl new file mode 100644 index 0000000..56c1724 --- /dev/null +++ b/docker/docker-back.hcl @@ -0,0 +1,53 @@ +variable "DOCKER_REGISTRY" { + default = "ghcr.io" +} +variable "DOCKER_ORG" { + default = "darpa-askem" +} +variable "VERSION" { + default = "local" +} + +# ---------------------------------------------------------------------------------------------------------------------- + +function "tag" { + params = [image_name, prefix, suffix] + result = [ "${DOCKER_REGISTRY}/${DOCKER_ORG}/${image_name}:${check_prefix(prefix)}${VERSION}${check_suffix(suffix)}" ] +} + +function "check_prefix" { + params = [tag] + result = notequal("",tag) ? "${tag}-": "" +} + +function "check_suffix" { + params = [tag] + result = notequal("",tag) ? "-${tag}": "" +} + +# ---------------------------------------------------------------------------------------------------------------------- + +group "prod" { + targets = ["simulation-scheduler"] +} + +group "default" { + targets = ["simulation-scheduler-base"] +} + +# ---------------------------------------------------------------------------------------------------------------------- + +# Removed linux/arm64 for now to ass CI build - Dec 2022 +target "_platforms" { + platforms = ["linux/amd64"] +} + +target "simulation-service-base" { + context = ".." + tags = tag("simulation-scheduler", "", "") + dockerfile = "Dockerfile.api" +} + +target "simulation-service" { + inherits = ["_platforms", "simulation-service-base"] +} \ No newline at end of file diff --git a/src/Scheduler.jl b/src/Scheduler.jl index 6f3cb5c..38f3042 100644 --- a/src/Scheduler.jl +++ b/src/Scheduler.jl @@ -30,7 +30,6 @@ Transform request body into splattable dict with correct types """ function get_args(req::Request)::Dict{Symbol,Any} args = json(req, Dict{Symbol, Any}) - # TODO(five): Make conversions more visible (MOVE TO TOP OF FILE?) function coerce!(key) # Is there a more idiomatic way of doing this if haskey(args, key) args[key] = conversions_for_valid_inputs[key](args[key]) diff --git a/test/runtests.jl b/test/runtests.jl new file mode 100644 index 0000000..f4f3b56 --- /dev/null +++ b/test/runtests.jl @@ -0,0 +1,7 @@ +import Test: @test + +# TODO(five): Add actual tests for SciML operations +@test 1 == 1 + +# TODO(five): Add actual tests for scheduler API +@test 2 == 2 \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29..0000000