From f00a67bc5b31b5d5ecb05a3ad90746db73563afe Mon Sep 17 00:00:00 2001 From: Prabhu Subramanian Date: Sat, 21 Sep 2024 17:29:55 +0100 Subject: [PATCH] Remove upstream astgen Signed-off-by: Prabhu Subramanian --- .github/workflows/pr.yml | 11 +++-- .github/workflows/release.yml | 2 +- .github/workflows/repotests.yml | 11 ++++- build.sbt | 76 --------------------------------- 4 files changed, 19 insertions(+), 81 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 56d90f0..9a43712 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -38,12 +38,16 @@ jobs: uses: graalvm/setup-graalvm@v1 with: distribution: 'graalvm-community' - java-version: '22' + java-version: '23' github-token: ${{ secrets.GITHUB_TOKEN }} native-image-job-reports: 'true' cache: 'sbt' - run: | - sbt stage astGenDlTask + sbt stage createDistribution + cd wrapper/nodejs + bash build.sh + npm install -g . + cd ../.. ./atom.sh --remove-atom -o /tmp/java.atom -l java $GITHUB_WORKSPACE/repotests/shiftleft-java-example -Dlog4j.configurationFile=log4j2.xml ./atom.sh --remove-atom -o /tmp/juice.atom -l js $GITHUB_WORKSPACE/repotests/juice-shop -Dlog4j.configurationFile=log4j2.xml ./atom.sh --remove-atom -o /tmp/ts.atom -l js $GITHUB_WORKSPACE/repotests/shiftleft-ts-example -Dlog4j.configurationFile=log4j2.xml @@ -72,9 +76,10 @@ jobs: ./atom.sh usages -o /tmp/DjanGoat.atom -l python $GITHUB_WORKSPACE/repotests/DjanGoat -Dlog4j.configurationFile=log4j2.xml --slice-outfile /tmp/DjanGoat.usages.json env: JAVA_TOOL_OPTIONS: "-Dfile.encoding=UTF-8" - if: runner.os != 'Windows' - run: | bash ci/native-image.sh + ./target/graalvm-native-image/atom --remove-atom -o /tmp/java.atom -l java $GITHUB_WORKSPACE/repotests/shiftleft-java-example -Dlog4j.configurationFile=log4j2.xml + ./target/graalvm-native-image/atom --remove-atom -o /tmp/juice.atom -l js $GITHUB_WORKSPACE/repotests/juice-shop -Dlog4j.configurationFile=log4j2.xml env: JAVA_TOOL_OPTIONS: "-Dfile.encoding=UTF-8" shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index df08dba..0e1cbe6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -72,7 +72,7 @@ jobs: tar -xvf upx-4.2.2-amd64_linux.tar.xz chmod +x upx-4.2.2-amd64_linux/upx sudo cp upx-4.2.2-amd64_linux/upx /usr/local/bin/ - sbt stage astGenDlTask assembly createDistribution + sbt stage assembly createDistribution sha512sum target/atom.zip > target/atom.zip.sha512 bash ci/native-image.sh cp target/graalvm-native-image/atom target/graalvm-native-image/atom-amd64 diff --git a/.github/workflows/repotests.yml b/.github/workflows/repotests.yml index 5631340..a781bce 100644 --- a/.github/workflows/repotests.yml +++ b/.github/workflows/repotests.yml @@ -81,12 +81,16 @@ jobs: run: brew install sbt if: runner.os == 'macOS' - run: | - sbt stage astGenDlTask + sbt stage createDistribution python -m pip install atom-tools env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} JAVA_TOOL_OPTIONS: "-Dfile.encoding=UTF-8" - run: | + cd wrapper/nodejs + bash build.sh + npm install -g . + cd ../.. ./atom.sh --remove-atom -o /tmp/java.atom -l java $GITHUB_WORKSPACE/repotests/shiftleft-java-example -Dlog4j.configurationFile=log4j2.xml ./atom.sh --remove-atom -o /tmp/juice.atom -l js $GITHUB_WORKSPACE/repotests/juice-shop -Dlog4j.configurationFile=log4j2.xml ./atom.sh --remove-atom -o /tmp/ts.atom -l js $GITHUB_WORKSPACE/repotests/shiftleft-ts-example -Dlog4j.configurationFile=log4j2.xml @@ -115,6 +119,11 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} JAVA_TOOL_OPTIONS: "-Dfile.encoding=UTF-8" - run: | + cd wrapper/nodejs + .\build.ps1 + npm install -g . + cd ../.. + .\atom.bat usages --remove-atom -o $env:GITHUB_WORKSPACE\\repotests\\juice-shop\\jshop.atom -l js $env:GITHUB_WORKSPACE\\repotests\\juice-shop --slice-outfile $env:GITHUB_WORKSPACE\\repotests\\juice-shop\\jshop.usages.json .\atom.bat usages --extract-endpoints --remove-atom -o $env:GITHUB_WORKSPACE\\repotests\\DjanGoat\\py3.atom -l python $env:GITHUB_WORKSPACE\\repotests\\DjanGoat --slice-outfile $env:GITHUB_WORKSPACE\\repotests\\DjanGoat\\py.usages.json python -m json.tool $env:GITHUB_WORKSPACE\\repotests\\DjanGoat\\openapi.generated.json if: runner.os == 'Windows' diff --git a/build.sbt b/build.sbt index 41a68b1..b53e86a 100644 --- a/build.sbt +++ b/build.sbt @@ -7,8 +7,6 @@ val chenVersion = "2.1.8" lazy val atom = Projects.atom -val astGenVersion = "3.5.0" - libraryDependencies ++= Seq( "com.github.pathikrit" %% "better-files" % "3.9.2", "com.github.scopt" %% "scopt" % "4.1.0", @@ -68,80 +66,6 @@ Universal / mappings := (Universal / mappings).value.filter { enablePlugins(JavaAppPackaging, ClasspathJarPlugin, GraalVMNativeImagePlugin) -lazy val AstgenWin = "astgen-win.exe" -lazy val AstgenLinux = "astgen-linux" -lazy val AstgenLinuxArm = "astgen-linux-arm" -lazy val AstgenMac = "astgen-macos" -lazy val AstgenMacArm = "astgen-macos-arm" - -lazy val astGenDlUrl = settingKey[String]("astgen download url") -astGenDlUrl := s"https://github.com/joernio/astgen/releases/download/v${astGenVersion}/" - -lazy val astGenBinaryNames = taskKey[Seq[String]]("astgen binary names") -astGenBinaryNames := { - if (sys.props.get("ALL_PLATFORMS").contains("TRUE")) { - Seq(AstgenWin, AstgenLinux, AstgenMac, AstgenMacArm) - } else { - Environment.operatingSystem match { - case Environment.OperatingSystemType.Windows => - Seq(AstgenWin) - case Environment.OperatingSystemType.Linux => - Environment.architecture match { - case Environment.ArchitectureType.X86 => Seq(AstgenLinux) - case Environment.ArchitectureType.ARM => Seq(AstgenLinuxArm) - } - case Environment.OperatingSystemType.Mac => - Environment.architecture match { - case Environment.ArchitectureType.X86 => Seq(AstgenMac) - case Environment.ArchitectureType.ARM => Seq(AstgenMacArm) - } - case Environment.OperatingSystemType.Unknown => - Seq(AstgenWin, AstgenLinux, AstgenMac, AstgenMacArm) - } - } -} - -lazy val astGenDlTask = taskKey[Unit](s"Download astgen binaries") -astGenDlTask := { - val astGenDir = baseDirectory.value / "bin" / "astgen" - astGenDir.mkdirs() - - astGenBinaryNames.value.foreach { fileName => - val dest = astGenDir / fileName - if (!dest.exists) { - val url = s"${astGenDlUrl.value}$fileName" - val downloadedFile = SimpleCache.downloadMaybe(url) - IO.copyFile(downloadedFile, dest) - } - } - - val distDir = (Universal / stagingDirectory).value / "bin" / "astgen" - distDir.mkdirs() - IO.copyDirectory(astGenDir, distDir) - - // permissions are lost during the download; need to set them manually - astGenDir.listFiles().foreach(_.setExecutable(true, false)) - distDir.listFiles().foreach(_.setExecutable(true, false)) -} - -lazy val astGenSetAllPlatforms = taskKey[Unit](s"Set ALL_PLATFORMS") -astGenSetAllPlatforms := { System.setProperty("ALL_PLATFORMS", "TRUE") } - -stage := Def - .sequential(astGenSetAllPlatforms, Universal / stage) - .andFinally(System.setProperty("ALL_PLATFORMS", "FALSE")) - .value - -// Also remove astgen binaries with clean, e.g., to allow for updating them. -// Sadly, we can't define the bin/ folders globally, -// as .value can only be used within a task or setting macro -cleanFiles ++= Seq( - baseDirectory.value / "bin" / "astgen", - (Universal / stagingDirectory).value / "bin" / "astgen" -) ++ astGenBinaryNames.value.map(fileName => - SimpleCache.encodeFile(s"${astGenDlUrl.value}$fileName") -) - ThisBuild / licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")) Global / onChangedBuildSource := ReloadOnSourceChanges