Skip to content

Commit b7e5c30

Browse files
authored
Scala repo tests (#184)
Signed-off-by: Prabhu Subramanian <[email protected]>
1 parent ee54d0e commit b7e5c30

File tree

11 files changed

+104
-16
lines changed

11 files changed

+104
-16
lines changed

.github/workflows/container-tests.yml

+22-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ concurrency:
66
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
77
cancel-in-progress: true
88
jobs:
9-
ruby-samples:
9+
lang-container-tests:
1010
strategy:
1111
fail-fast: false
1212
matrix:
@@ -16,8 +16,7 @@ jobs:
1616
- uses: actions/checkout@v4
1717
- name: setup paths
1818
run: |
19-
mkdir -p repotests
20-
mkdir -p rubyresults
19+
mkdir -p repotests rubyresults scalaresults
2120
- uses: actions/checkout@v4
2221
with:
2322
repository: 'campsite/campsite'
@@ -33,7 +32,12 @@ jobs:
3332
repository: 'OWASP/railsgoat'
3433
path: 'repotests/railsgoat'
3534
ref: 'c1e8ff1e3b24a1c48fcfc9fbee0f65dc296b49d9'
36-
- name: generate usages sbom - bionomia
35+
- uses: actions/checkout@v4
36+
with:
37+
repository: 'playframework/play-samples'
38+
path: 'repotests/play-samples'
39+
ref: '0dccba17856e89dbb5e457ab760efb14cc691395'
40+
- name: generate usages - bionomia
3741
run: |
3842
mkdir -p $GITHUB_WORKSPACE/rubyresults/bionomia
3943
cd repotests/bionomia
@@ -42,26 +46,37 @@ jobs:
4246
docker run --rm -v /tmp:/tmp -v $(pwd):/app:rw -t ghcr.io/appthreat/atom:main atom usages -l ruby -o /app/app.atom -s /app/usages.slices.json /app
4347
ls -lh
4448
cp *.slices.json $GITHUB_WORKSPACE/rubyresults/bionomia
45-
- name: generate usages sbom - railsgoat
49+
- name: generate usages - railsgoat
4650
run: |
4751
mkdir -p $GITHUB_WORKSPACE/rubyresults/railsgoat
4852
cd repotests/railsgoat
4953
docker run --rm -v /tmp:/tmp -v $(pwd):/app:rw -t ghcr.io/appthreat/atom:main atom usages --extract-endpoints -l ruby -o /app/app.atom -s /app/usages.slices.json /app
5054
ls -lh
5155
cp *.slices.json $GITHUB_WORKSPACE/rubyresults/railsgoat
52-
- name: generate usages sbom - campsite
56+
- name: generate usages - campsite
5357
run: |
5458
mkdir -p $GITHUB_WORKSPACE/rubyresults/campsite
5559
cd repotests/campsite/api
5660
docker run --rm -v /tmp:/tmp -v $(pwd):/app:rw -t ghcr.io/appthreat/atom:main atom usages -l ruby -o /app/app.atom -s /app/usages.slices.json /app
5761
ls -lh
5862
cp *.slices.json $GITHUB_WORKSPACE/rubyresults/campsite
63+
- name: generate usages - play-samples
64+
run: |
65+
mkdir -p $GITHUB_WORKSPACE/scalaresults/play-samples
66+
cd repotests/play-samples/play-scala-rest-api-example
67+
docker run --rm -v /tmp:/tmp -v $(pwd):/app:rw -w /app -t ghcr.io/appthreat/atom:main atom usages --extract-endpoints -l scala -o /app/app.atom -s /app/usages.slices.json /app
68+
ls -lh
69+
cp *.slices.json $GITHUB_WORKSPACE/scalaresults/play-samples
5970
- uses: actions/upload-artifact@v4
6071
with:
6172
name: rubyresults
6273
path: rubyresults
6374
if: matrix.os == 'ubuntu-24.04'
64-
75+
- uses: actions/upload-artifact@v4
76+
with:
77+
name: scalaresults
78+
path: scalaresults
79+
if: matrix.os == 'ubuntu-24.04'
6580
npm-latest-tests:
6681
strategy:
6782
fail-fast: false

.github/workflows/containers.yml

+12
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
distribution: 'temurin'
3535
java-version: '22'
3636
- uses: sbt/setup-sbt@v1
37+
- uses: coursier/setup-action@v1
38+
with:
39+
apps: scala3 scalac
3740
- name: Use Node.js
3841
uses: actions/setup-node@v4
3942
with:
@@ -102,6 +105,9 @@ jobs:
102105
distribution: 'temurin'
103106
java-version: '22'
104107
- uses: sbt/setup-sbt@v1
108+
- uses: coursier/setup-action@v1
109+
with:
110+
apps: scala3 scalac
105111
- name: Use Node.js
106112
uses: actions/setup-node@v4
107113
with:
@@ -201,6 +207,9 @@ jobs:
201207
distribution: 'temurin'
202208
java-version: '22'
203209
- uses: sbt/setup-sbt@v1
210+
- uses: coursier/setup-action@v1
211+
with:
212+
apps: scala3 scalac
204213
- name: Use Node.js
205214
uses: actions/setup-node@v4
206215
with:
@@ -270,6 +279,9 @@ jobs:
270279
distribution: 'temurin'
271280
java-version: '22'
272281
- uses: sbt/setup-sbt@v1
282+
- uses: coursier/setup-action@v1
283+
with:
284+
apps: scala3 scalac
273285
- name: Use Node.js
274286
uses: actions/setup-node@v4
275287
with:

.github/workflows/nodejstests.yml

+24
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,21 @@ jobs:
5555
repository: 'OWASP/railsgoat'
5656
path: 'repotests/railsgoat'
5757
ref: 'c1e8ff1e3b24a1c48fcfc9fbee0f65dc296b49d9'
58+
- uses: actions/checkout@v4
59+
with:
60+
repository: 'playframework/play-samples'
61+
path: 'repotests/play-samples'
62+
ref: '0dccba17856e89dbb5e457ab760efb14cc691395'
5863
- uses: coursier/cache-action@v6
5964
- name: Set up JDK
6065
uses: actions/setup-java@v4
6166
with:
6267
distribution: 'temurin'
6368
java-version: ${{ matrix.java-version }}
6469
- uses: sbt/setup-sbt@v1
70+
- uses: coursier/setup-action@v1
71+
with:
72+
apps: scala3 scalac
6573
- name: "Install PHP"
6674
uses: "shivammathur/setup-php@v2"
6775
with:
@@ -82,6 +90,7 @@ jobs:
8290
if: runner.os == 'Linux'
8391
- run: |
8492
sbt stage createDistribution
93+
python -m pip install atom-tools
8594
cd wrapper/nodejs
8695
bash build.sh
8796
sudo npm install -g .
@@ -96,6 +105,7 @@ jobs:
96105
atom -l c -o ${GITHUB_WORKSPACE}/repotests/libexpat/app.atom ${GITHUB_WORKSPACE}/repotests/libexpat
97106
atom -o ${GITHUB_WORKSPACE}/repotests/railsgoat/app.atom -l ruby ${GITHUB_WORKSPACE}/repotests/railsgoat
98107
atom -o ${GITHUB_WORKSPACE}/repotests/bionomia/app.atom -l ruby ${GITHUB_WORKSPACE}/repotests/bionomia
108+
atom -o ${GITHUB_WORKSPACE}/repotests/play-samples/play-scala-rest-api-example/app.atom -l scala ${GITHUB_WORKSPACE}/repotests/play-samples/play-scala-rest-api-example
99109
env:
100110
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101111
nodejs-testing-windows:
@@ -110,6 +120,10 @@ jobs:
110120
uses: actions/setup-node@v4
111121
with:
112122
node-version: ${{ matrix.node-version }}
123+
- name: Set up Python
124+
uses: actions/setup-python@v5
125+
with:
126+
python-version: '3.12'
113127
- uses: actions/checkout@v4
114128
with:
115129
repository: 'ShiftLeftSecurity/shiftleft-java-example'
@@ -130,17 +144,26 @@ jobs:
130144
with:
131145
repository: 'HooliCorp/DjanGoat'
132146
path: 'repotests/DjanGoat'
147+
- uses: actions/checkout@v4
148+
with:
149+
repository: 'playframework/play-samples'
150+
path: 'repotests/play-samples'
151+
ref: '0dccba17856e89dbb5e457ab760efb14cc691395'
133152
- uses: coursier/cache-action@v6
134153
- name: Set up JDK
135154
uses: actions/setup-java@v4
136155
with:
137156
distribution: 'temurin'
138157
java-version: ${{ matrix.java-version }}
139158
- uses: sbt/setup-sbt@v1
159+
- uses: coursier/setup-action@v1
160+
with:
161+
apps: scala3 scalac
140162
- name: build
141163
shell: pwsh
142164
run: |
143165
sbt stage createDistribution
166+
python -m pip install atom-tools
144167
cd wrapper\\nodejs
145168
copy ..\..\target\atom.zip plugins\
146169
Expand-Archive -Path ..\..\target\atom.zip -DestinationPath plugins\ -Force
@@ -161,6 +184,7 @@ jobs:
161184
atom -l python --remove-atom -o $env:GITHUB_WORKSPACE\\repotests\\DjanGoat\\app.atom $env:GITHUB_WORKSPACE\\repotests\\DjanGoat
162185
atom parsedeps --remove-atom -l python -o $env:GITHUB_WORKSPACE\\repotests\\DjanGoat\\app.atom $env:GITHUB_WORKSPACE\\repotests\\DjanGoat
163186
atom -l c -o $env:GITHUB_WORKSPACE\\repotests\\libexpat\\app.atom $env:GITHUB_WORKSPACE\\repotests\\libexpat
187+
atom -l scala -o $env:GITHUB_WORKSPACE\\repotests\\play-samples\\play-scala-rest-api-example\\app.atom $env:GITHUB_WORKSPACE\\repotests\\play-samples\\play-scala-rest-api-example
164188
- name: test3
165189
shell: cmd
166190
run: |

.github/workflows/npm-release.yml

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ jobs:
3131
distribution: 'temurin'
3232
java-version: '21'
3333
- uses: sbt/setup-sbt@v1
34+
- uses: coursier/setup-action@v1
35+
with:
36+
apps: scala3 scalac
3437
- name: Build
3538
run: |
3639
sudo apt update -y

.github/workflows/pr.yml

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ jobs:
6161
native-image-job-reports: 'true'
6262
cache: 'sbt'
6363
- uses: sbt/setup-sbt@v1
64+
- uses: coursier/setup-action@v1
65+
with:
66+
apps: scala3 scalac
6467
- run: |
6568
sbt stage createDistribution
6669
cd wrapper/nodejs

.github/workflows/release.yml

+9
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ jobs:
7373
native-image-job-reports: 'true'
7474
cache: 'sbt'
7575
- uses: sbt/setup-sbt@v1
76+
- uses: coursier/setup-action@v1
77+
with:
78+
apps: scala3 scalac
7679
- uses: oras-project/setup-oras@v1
7780
- run: |
7881
wget https://github.com/upx/upx/releases/download/v5.0.0/upx-5.0.0-amd64_linux.tar.xz
@@ -145,6 +148,9 @@ jobs:
145148
native-image-job-reports: 'true'
146149
cache: 'sbt'
147150
- uses: sbt/setup-sbt@v1
151+
- uses: coursier/setup-action@v1
152+
with:
153+
apps: scala3 scalac
148154
- uses: oras-project/setup-oras@v1
149155
- run: |
150156
wget https://github.com/upx/upx/releases/download/v5.0.0/upx-5.0.0-arm64_linux.tar.xz
@@ -199,6 +205,9 @@ jobs:
199205
native-image-job-reports: 'true'
200206
cache: 'sbt'
201207
- uses: sbt/setup-sbt@v1
208+
- uses: coursier/setup-action@v1
209+
with:
210+
apps: scala3 scalac
202211
- uses: oras-project/setup-oras@v1
203212
- run: |
204213
brew install coreutils

.github/workflows/repotests.yml

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: repotests
22
on:
33
push:
44
branches:
5-
- main
65
- feature/*
76
workflow_dispatch:
87
concurrency:
@@ -70,13 +69,21 @@ jobs:
7069
repository: 'OWASP/railsgoat'
7170
path: 'repotests/railsgoat'
7271
ref: 'c1e8ff1e3b24a1c48fcfc9fbee0f65dc296b49d9'
72+
- uses: actions/checkout@v4
73+
with:
74+
repository: 'playframework/play-samples'
75+
path: 'repotests/play-samples'
76+
ref: '0dccba17856e89dbb5e457ab760efb14cc691395'
7377
- uses: coursier/cache-action@v6
7478
- name: Set up JDK
7579
uses: actions/setup-java@v4
7680
with:
7781
distribution: 'temurin'
7882
java-version: ${{ matrix.java-version }}
7983
- uses: sbt/setup-sbt@v1
84+
- uses: coursier/setup-action@v1
85+
with:
86+
apps: scala3 scalac
8087
- name: Use Node.js ${{ matrix.node-version }}
8188
uses: actions/setup-node@v4
8289
with:
@@ -135,6 +142,14 @@ jobs:
135142
./atom.sh usages --extract-endpoints --remove-atom -o /tmp/railsgoat2.atom -l ruby $GITHUB_WORKSPACE/repotests/railsgoat -Dlog4j.configurationFile=log4j2.xml --slice-outfile /tmp/railsgoat2.usages.json
136143
./atom.sh usages --remove-atom -o /tmp/bionomia2.atom -l ruby $GITHUB_WORKSPACE/repotests/bionomia -Dlog4j.configurationFile=log4j2.xml --slice-outfile /tmp/bionomia2.usages.json
137144
./atom.sh --remove-atom -o /tmp/java-sec-code.atom -l java $GITHUB_WORKSPACE/repotests/java-sec-code -Dlog4j.configurationFile=log4j2.xml -x --export-dir gml_exports
145+
146+
./atom.sh --remove-atom -o /tmp/play-scala-slick-example.atom -l scala $GITHUB_WORKSPACE/repotests/play-samples/play-scala-slick-example
147+
ls -lh $GITHUB_WORKSPACE/repotests/play-samples/play-scala-slick-example
148+
./atom.sh --remove-atom -o /tmp/play-scala-rest-api-example.atom -l scala $GITHUB_WORKSPACE/repotests/play-samples/play-scala-rest-api-example
149+
./atom.sh usages --extract-endpoints --remove-atom -o /tmp/play-scala-rest-api-example.atom -l scala $GITHUB_WORKSPACE/repotests/play-samples/play-scala-rest-api-example --slice-outfile /tmp/scala-rest.usages.json
150+
ls -lh $GITHUB_WORKSPACE/repotests/play-samples/play-scala-rest-api-example
151+
./atom.sh --remove-atom -o /tmp/play-scala-grpc-example.atom -l scala $GITHUB_WORKSPACE/repotests/play-samples/play-scala-grpc-example
152+
ls -lh $GITHUB_WORKSPACE/repotests/play-samples/play-scala-grpc-example
138153
ls -lh .
139154
if: runner.os != 'Windows'
140155
env:

ci/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,6 @@ RUN unzip -q atom.zip \
114114
&& rbastgen --help \
115115
&& microdnf clean all
116116

117+
WORKDIR /app
118+
117119
CMD ["/opt/bin/atom"]

ci/Dockerfile.sle

+2
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,6 @@ RUN unzip -q atom.zip \
9696
&& rbastgen --help \
9797
&& zypper clean -a
9898

99+
WORKDIR /app
100+
99101
CMD ["/opt/bin/atom"]

src/main/scala/io/appthreat/atom/Atom.scala

+10-3
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,16 @@ object Atom:
540540
)
541541
result match
542542
case Success(_) =>
543-
println(
544-
s"Semantic slices file '${semanticSlicesFile}' created successfully."
545-
)
543+
if File(semanticSlicesFile).exists then
544+
println(
545+
s"Semantic slices file '${semanticSlicesFile}' created successfully."
546+
)
547+
else{
548+
println(s"scalasem ${workDir} ${semanticSlicesFile}")
549+
println(
550+
s"scalasem command did not produce the semantic slices file."
551+
)
552+
}
546553
case Failure(exception) =>
547554
println(
548555
s"Failed to run scalasem. Use the atom container image and re-run this command. Exception: ${exception.getMessage}"

wrapper/nodejs/scalasem.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ import {
1515
} from "node:fs";
1616

1717
function main(argvs) {
18-
if (!detectScala()) {
18+
if (!detectScala() && !detectScalac()) {
1919
console.warn("Scala is not installed!");
2020
return false;
2121
}
22-
if (!detectScalac()) {
23-
console.warn("Scalac is not installed!");
24-
return false;
25-
}
2622
let configFiles = getAllFiles(argvs[0], "routes");
2723
configFiles = configFiles.concat(getAllFiles(argvs[0], ".conf"));
2824
let tastyFiles = getAllFiles(argvs[0], ".tasty");

0 commit comments

Comments
 (0)