Skip to content

Commit

Permalink
New, faster runner (#1922)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto authored Jan 9, 2025
1 parent d2e1343 commit 0fea809
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 32 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, ARM64]
steps:
- uses: actions/checkout@v4
- run: |
Expand All @@ -28,14 +28,13 @@ jobs:
java-version: "17"
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"
- uses: actions/setup-node@v4
with:
node-version: "18"
- name: Setup Go
uses: actions/setup-go@v5
- uses: actions/setup-go@v5
with:
go-version: 1.21
go-version-file: cpg-language-go/src/test/resources/golang/integration/go.mod
- name: Setup neo4j
run: |
docker run -d --env NEO4J_AUTH=neo4j/password -p7474:7474 -p7687:7687 -e NEO4JLABS_PLUGINS='["apoc"]' neo4j:5 || true
Expand All @@ -56,10 +55,9 @@ jobs:
echo "version=$VERSION" >> $GITHUB_ENV
- name: Install JEP
run: |
python3 -m venv ~/.virtualenvs/cpg
source ~/.virtualenvs/cpg/bin/activate
pip3 install jep==$(grep "black.ninia:jep" gradle/libs.versions.toml | grep -o -E "[0-9]\d*(\.[0-9]\d*)*")
if [ -d "/opt/hostedtoolcache/Python" ]; then
find /opt/hostedtoolcache/Python/ -name libjep.so -exec sudo cp '{}' /usr/lib/ \;
fi
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build ${{ env.version }}
Expand Down
34 changes: 22 additions & 12 deletions cpg-language-go/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
* \______/ \__| \______/
*
*/
import de.undercouch.gradle.tasks.download.Download

plugins {
id("cpg.frontend-conventions")
alias(libs.plugins.download)
}

publishing {
Expand All @@ -44,18 +47,25 @@ dependencies {
testImplementation(project(":cpg-analysis"))
}

open class DownloadTask @Inject constructor(@Internal val op: ExecOperations) : DefaultTask()
tasks {
val downloadLibGoAST by registering(Download::class) {
val version = "v0.0.4"

val downloadLibGoAST = tasks.register<DownloadTask>("downloadLibGoAST") {
doLast {
op.exec {
commandLine("./download.sh")
.setStandardOutput(System.out)
.workingDir(project.projectDir.resolve("src/main/resources"))
}
src(listOf(
"https://github.com/Fraunhofer-AISEC/libgoast/releases/download/${version}/libgoast-arm64.dylib",
"https://github.com/Fraunhofer-AISEC/libgoast/releases/download/${version}/libgoast-amd64.dylib",
"https://github.com/Fraunhofer-AISEC/libgoast/releases/download/${version}/libgoast-arm64.so",
"https://github.com/Fraunhofer-AISEC/libgoast/releases/download/${version}/libgoast-amd64.so"
))
dest(projectDir.resolve("src/main/resources"))
onlyIfModified(true)
}
}

tasks.processResources {
dependsOn(downloadLibGoAST)
}
processResources {
dependsOn(downloadLibGoAST)
}

sourcesJar {
dependsOn(downloadLibGoAST)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ class GoLanguageFrontendTest : BaseTest() {
@Test
fun testBuildTags() {
val stdLib = Path.of("src", "test", "resources", "golang-std")
val topLevel = Path.of("src", "test", "resources", "golang", "buildtags")
val topLevel = Path.of("src", "test", "resources", "golang", "integration")

// make sure we parse main.go as the last
val files =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class IntegrationTest {

@Test
fun testProject() {
val project = buildProject("src/test/resources/golang/buildtags", "darwin", "arm64")
val project = buildProject("src/test/resources/golang/integration", "darwin", "arm64")

val app = project.components[APPLICATION_LOCAL_NAME]
assertNotNull(app)
Expand Down
3 changes: 0 additions & 3 deletions cpg-language-go/src/test/resources/golang/buildtags/go.mod

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"mymodule.io/buildtags"
"mymodule.io/integration"
)

func main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

//go:build darwin

// Package buildtags is awesome
package buildtags
// Package integration is awesome
package integration

func OS() string {
return "darwin"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package buildtags
package integration

func someSpecific() {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Some other header

// Package buildtags is awesome
package buildtags
// Package integration is awesome
package integration

func OS() string {
return "ios"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package buildtags
package integration

func OS() string {
return "linux"
Expand Down
3 changes: 3 additions & 0 deletions cpg-language-go/src/test/resources/golang/integration/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module mymodule.io/integration

go 1.21.1
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin"}
dokka = { id = "org.jetbrains.dokka", version.ref = "kotlin" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
node = { id = "com.github.node-gradle.node", version = "7.1.0"}
download = { id = "de.undercouch.download", version = "5.6.0" }

0 comments on commit 0fea809

Please sign in to comment.