Skip to content

Commit

Permalink
Bash tests (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
pshirshov authored Nov 5, 2024
1 parent 115d2a6 commit 4a296c6
Show file tree
Hide file tree
Showing 66 changed files with 263 additions and 8,341 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ jobs:
# files: cobertura.xml,scoverage.xml
# flags: unittests

test-compiler:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test: [ 'test-scala', 'test-cs', 'test-ts', 'test-pb' ]
scala: [ '2.12', '2.13' ]
steps:
- uses: 7mind/github-env@minimal
- name: Test compiler
env:
SCALA_VERSION: ${{ matrix.scala }}
run: ./build.sh nix gen ${{ matrix.test }}

publish-npm:
runs-on: ubuntu-latest
needs: [ 'checksecret' ]
Expand Down Expand Up @@ -84,7 +98,7 @@ jobs:

publish-scala:
runs-on: ubuntu-latest
needs: [ 'build', 'checksecret' ]
needs: [ 'build', 'test-compiler', 'checksecret' ]
if: needs.checksecret.outputs.HAVE_SECRETS == 'true'
strategy:
fail-fast: false
Expand All @@ -111,7 +125,7 @@ jobs:
echo "$SONATYPE_CREDENTIALS_FILE" > "$SONATYPE_SECRET"
openssl aes-256-cbc -K ${OPENSSL_KEY} -iv ${OPENSSL_IV} -in secrets.tar.enc -out secrets.tar -d
tar xvf secrets.tar
fi
fi
./build.sh nix gen publish-scala
all-good:
Expand Down
23 changes: 0 additions & 23 deletions .jvmopts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,7 @@
-XX:+OmitStackTraceInFastThrow
-XX:SoftRefLRUPolicyMSPerMB=50
-Dsun.io.useCanonCaches=false
-noverify
-server

#-Xshare:on

#-Xshare:dump
#-Xlog:class+load=info

-XX:+UseG1GC

# Enable ZGC
#-XX:+UnlockExperimentalVMOptions
#-XX:+UseZGC

# Enable Graal JIT
#-XX:+UnlockExperimentalVMOptions
#-XX:+EnableJVMCI
#-XX:+UseJVMCICompiler

# Bumping JIT inline-level increases performance of Scala code
# https://www.reddit.com/r/scala/comments/cigh0t/these_go_to_eighteen_c_jon_pretty/
# https://scalacenter.github.io/bloop/docs/performance-guide#tweak-the-java-jit
# https://twitter.com/leifwickland/status/1179419045055086595
-XX:MaxInlineLevel=18
# These seem to cause sbt import slowdown :\
#-XX:MaxInlineSize=270
#-XX:MaxTrivialSize=12
19 changes: 18 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,24 @@ lazy val `idealingua-v1` = (project in file("."))
Some(Opts.resolver.sonatypeSnapshots)
})
,
ThisBuild / credentials += Credentials(file(".secrets/credentials.sonatype-nexus.properties")),
ThisBuild / credentials ++=
{
val credTarget = Path.userHome / ".sbt" / "secrets" / "credentials.sonatype-nexus.properties"
if (credTarget.exists) {
Seq(Credentials(credTarget))
} else {
Seq.empty
}
},
ThisBuild / credentials ++=
{
val credTarget = file(".") / ".secrets" / "credentials.sonatype-nexus.properties"
if (credTarget.exists) {
Seq(Credentials(credTarget))
} else {
Seq.empty
}
},
ThisBuild / homepage := Some(url("https://izumi.7mind.io")),
ThisBuild / licenses := Seq("BSD-style" -> url("http://www.opensource.org/licenses/bsd-license.php")),
ThisBuild / developers := List(
Expand Down
5 changes: 2 additions & 3 deletions devops/.env-basic.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env bash
set -xeuo pipefail

set -e
set -x

export CI_BUILD_UNIQ_SUFFIX="${CI_BUILD_UNIQ_SUFFIX:-$(date +%s)}"
export IDEALINGUA_VERSION=$(cat version.sbt | sed -r 's/.*\"(.*)\".**/\1/' | sed -E "s/SNAPSHOT/build."${CI_BUILD_UNIQ_SUFFIX}"/")
7 changes: 4 additions & 3 deletions devops/.env.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env bash

set -e
set -x
set -xeuo pipefail

source ./devops/.env-basic.sh

export SCALA212=$(cat project/Deps.sc | grep 'val scala212 ' | sed -r 's/.*\"(.*)\".**/\1/')
export SCALA213=$(cat project/Deps.sc | grep 'val scala213 ' | sed -r 's/.*\"(.*)\".**/\1/')
export SCALA3=$(cat project/Deps.sc | grep 'val scala300 ' | sed -r 's/.*\"(.*)\".**/\1/')
Expand All @@ -19,3 +18,5 @@ esac

export SCALA_VERSION="$SCALA_VERSION"
export VERSION_COMMAND="++ $SCALA_VERSION"

env
4 changes: 1 addition & 3 deletions devops/.validate-publishing.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env bash

set -e
set -x
set -xeuo pipefail

([[ "$CI_PULL_REQUEST" == "true" ]] && echo "Publishing not allowed on P/Rs" && exit 0 || true)
([[ ! ("$CI_BRANCH" == "develop" || "$CI_BRANCH_TAG" =~ ^v.*$ ) ]] && echo "Publishing not allowed (CI_BRANCH=$CI_BRANCH, CI_BRANCH_TAG=$CI_BRANCH_TAG)" && exit 0) || true
5 changes: 1 addition & 4 deletions devops/coverage.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/usr/bin/env bash

set -e
set -x
set -xeuo pipefail

source ./devops/.env.sh
printenv

sbt -batch -no-colors -v clean coverage "$VERSION_COMMAND test" "$VERSION_COMMAND coverageReport"
4 changes: 1 addition & 3 deletions devops/gen.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env bash

set -e
set -x
set -xeuo pipefail

bash sbtgen.sc --js
6 changes: 2 additions & 4 deletions devops/publish-npm.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/usr/bin/env bash

set -e
set -x
set -xeuo pipefail

source ./devops/.env-basic.sh
printenv
env

source ./devops/.validate-publishing.sh

Expand Down
6 changes: 2 additions & 4 deletions devops/publish-nuget.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/usr/bin/env bash

set -e
set -x
set -xeuo pipefail

source ./devops/.env-basic.sh
printenv
env

source ./devops/.validate-publishing.sh

Expand Down
5 changes: 1 addition & 4 deletions devops/publish-scala.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/usr/bin/env bash

set -e
set -x
set -xeuo pipefail

source ./devops/.env.sh
printenv

source ./devops/.validate-publishing.sh

Expand Down
53 changes: 53 additions & 0 deletions devops/test-cs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -xeuo pipefail

source ./devops/.env.sh
printenv

refsdir="$PWD/idealingua-v1/idealingua-v1-test-defs/src/main/resources/refs/csharp"
refs="$(find "$refsdir" -name "*.dll" -exec echo "/reference:{}" \; | xargs -0 | tr '\n' ' ')"


function test_msbuild_prj() {
echo "IDL TEST ABOUT TO START: $1"
testname="$(basename $1)"
tmpdir="$(mktemp -d -t "$testname".XXXXXXXX)"

sbt "$VERSION_COMMAND ; idealingua-v1-compiler/run --root=$1 --source=$1/source --overlay=$1/overlay --target=$tmpdir :csharp -d layout=NUGET"

pushd .
cd $tmpdir/csharp

msbuild /t:Restore /t:Rebuild

for f in nuspec/*.nuspec
do
nuget pack "$f"
done

popd
echo "IDL TEST DONE: $1"
}

function test_plain_prj() {
echo "IDL TEST ABOUT TO START: $1"
testname="$(basename $1)"
tmpdir="$(mktemp -d -t "$testname".XXXXXXXX)"

sbt "$VERSION_COMMAND ; idealingua-v1-compiler/run --root=$1 --source=$1/source --overlay=$1/overlay --target=$tmpdir :csharp -d layout=PLAIN"

pushd .
cd $tmpdir/csharp

csc -target:library -out:tests.dll "-recurse:\\*.cs" $refs
cp "$refsdir"/*.dll .
nunit3-console tests.dll

popd
echo "IDL TEST DONE: $1"
}

find ./idealingua-v1/idealingua-v1-test-defs/src/main/resources/defs -maxdepth 1 -mindepth 1 -type d | while IFS= read -r file; do
test_msbuild_prj "$file"
test_plain_prj "$file"
done
30 changes: 30 additions & 0 deletions devops/test-pb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -xeuo pipefail

source ./devops/.env.sh

function test_pb_prj() {
echo "IDL TEST ABOUT TO START: $1"
testname="$(basename $1)"
tmpdir="$(mktemp -d -t "$testname".XXXXXXXX)"

sbt "$VERSION_COMMAND ; idealingua-v1-compiler/run --root=$1 --source=$1/source --overlay=$1/overlay --target=$tmpdir :protobuf"

pushd .
cd $tmpdir/protobuf

mkdir ./java-out
protoc --java_out=./java-out $(find ./ -iname '*.proto')

popd
echo "IDL TEST DONE: $1"
}

test_pb_prj ./idealingua-v1/idealingua-v1-test-defs/src/main/resources/defs/main-tests
test_pb_prj ./idealingua-v1/idealingua-v1-test-defs/src/main/resources/defs/overlays

# subdir is broken (nested generics)

#find ./idealingua-v1/idealingua-v1-test-defs/src/main/resources/defs -maxdepth 1 -mindepth 1 -type d | while IFS= read -r file; do
# test_pb_prj "$file"
#done
57 changes: 57 additions & 0 deletions devops/test-scala.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -xeuo pipefail

source ./devops/.env.sh

classpath="$(TERM=dumb sbt --batch --error "$VERSION_COMMAND ; export idealingua-v1-compiler/runtime:fullClasspath")"

function test_sbt_prj() {
echo "IDL TEST ABOUT TO START: $1"
testname="$(basename $1)"
tmpdir="$(mktemp -d -t "$testname".XXXXXXXX)"

sbt "$VERSION_COMMAND ; idealingua-v1-compiler/run --root=$1 --source=$1/source --overlay=$1/overlay --target=$tmpdir :scala -d layout=SBT"

pushd .
cd $tmpdir/scala
[[ -f build.sbt ]] || exit 1
sbt clean compile
popd
echo "IDL TEST DONE: $1"
}

function test_plain_prj() {
echo "IDL TEST ABOUT TO START: $1"
testname="$(basename $1)"
tmpdir="$(mktemp -d -t "$testname".XXXXXXXX)"

sbt "$VERSION_COMMAND ; idealingua-v1-compiler/run --root=$1 --source=$1/source --overlay=$1/overlay --target=$tmpdir :scala -d layout=PLAIN"

pushd .
cd $tmpdir/scala
files=$(find . -name '*.scala' -print0 | xargs -0)

mkdir ./target
cs \
launch \
scalac:"${SCALA_VERSION}" \
-- \
-deprecation \
-opt-warnings:_ \
-d \
./target \
-classpath "$classpath" \
${files}
popd
echo "IDL TEST DONE: $1"
}

find ./idealingua-v1/idealingua-v1-test-defs/src/main/resources/defs -maxdepth 1 -mindepth 1 -type d | while IFS= read -r file; do
test_sbt_prj "$file"
test_plain_prj "$file"
done


find ./idealingua-v1/idealingua-v1-test-defs/src/main/resources/defs-special -name 'scala-*' -maxdepth 1 -mindepth 1 -type d | while IFS= read -r file; do
test_plain_prj "$file"
done
45 changes: 45 additions & 0 deletions devops/test-ts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -xeuo pipefail

source ./devops/.env.sh

function test_yarn_prj() {
echo "IDL TEST ABOUT TO START: $1"
testname="$(basename $1)"
tmpdir="$(mktemp -d -t "$testname".XXXXXXXX)"

sbt "$VERSION_COMMAND ; idealingua-v1-compiler/run --root=$1 --source=$1/source --overlay=$1/overlay --target=$tmpdir :typescript -d layout=YARN"

pushd .
cd $tmpdir/typescript
[[ -f tsconfig.json ]] || exit 1

yarn install
yarn build

popd
echo "IDL TEST DONE: $1"
}

function test_plain_prj() {
echo "IDL TEST ABOUT TO START: $1"
testname="$(basename $1)"
tmpdir="$(mktemp -d -t "$testname".XXXXXXXX)"

sbt "$VERSION_COMMAND ; idealingua-v1-compiler/run --root=$1 --source=$1/source --overlay=$1/overlay --target=$tmpdir :typescript -d layout=PLAIN"

pushd .
cd $tmpdir/typescript
[[ -f tsconfig.json ]] || exit 1

yarn install
tsc -p tsconfig.json

popd
echo "IDL TEST DONE: $1"
}

find ./idealingua-v1/idealingua-v1-test-defs/src/main/resources/defs -maxdepth 1 -mindepth 1 -type d | while IFS= read -r file; do
test_yarn_prj "$file"
test_plain_prj "$file"
done
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
domain idltest.streams

data Nuthing {}

// NOTE: It's just a syntax. Streams aren't supported by transpilers yet. https://github.com/7mind/izumi/issues/89
streams TestStreams {
toclient empty(firstName: str, secondName: str)
Expand Down
Loading

0 comments on commit 4a296c6

Please sign in to comment.