Skip to content

Commit

Permalink
Building with a custom runner (#1243)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto authored Jul 19, 2023
1 parent d4a4358 commit 708ab68
Show file tree
Hide file tree
Showing 11 changed files with 490 additions and 879 deletions.
33 changes: 23 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
path: cpg-language-go/src/main/resources/libcpgo-arm64.dylib

build:
runs-on: ubuntu-latest
runs-on: [self-hosted, linux, x64, faster]
needs: build-cpgo-osx
steps:
- uses: actions/checkout@v3
Expand All @@ -59,16 +59,15 @@ jobs:
with:
distribution: "zulu"
java-version: "17"
cache: "gradle"
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/setup-node@v3
with:
node-version: "16"
node-version: "18"
- name: Setup neo4j
run: |
docker run -d --env NEO4J_AUTH=neo4j/password -p7474:7474 -p7687:7687 neo4j
docker run -d --env NEO4J_AUTH=neo4j/password -p7474:7474 -p7687:7687 neo4j || true
- name: Setup Go
uses: actions/setup-go@v4
with:
Expand Down Expand Up @@ -96,7 +95,9 @@ jobs:
- name: Install JEP
run: |
pip3 install jep==$(grep "black.ninia:jep" gradle/libs.versions.toml | grep -o -E "[0-9]\d*(\.[0-9]\d*)*")
find /opt/hostedtoolcache/Python/ -name libjep.so -exec sudo cp '{}' /usr/lib/ \;
if [ -d "/opt/hostedtoolcache/Python" ]; then
find /opt/hostedtoolcache/Python/ -name libjep.so -exec sudo cp '{}' /usr/lib/ \;
fi
- name: Install pycodestyle
run: |
pip3 install pycodestyle
Expand All @@ -123,25 +124,37 @@ jobs:
run: |
if [ "$SONAR_TOKEN" != "" ]
then
./gradlew --no-daemon --parallel -Pversion=$VERSION -Pexperimental -PenableJavaFrontend=true -PenableCXXFrontend=true -PenableGoFrontend=true -PenablePythonFrontend=true -PenableLLVMFrontend=true -PenableTypeScriptFrontend=true -Pintegration spotlessCheck -x spotlessApply build -x distZip -x distTar testCodeCoverageReport sonar \
./gradlew --no-daemon --parallel -Pversion=$VERSION -Pintegration spotlessCheck -x spotlessApply build -x distZip -x distTar testCodeCoverageReport sonar \
-Dsonar.projectKey=Fraunhofer-AISEC_cpg \
-Dsonar.organization=fraunhofer-aisec \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=$SONAR_TOKEN
else
./gradlew --no-daemon --parallel -Pversion=$VERSION -Pexperimental -PenableJavaFrontend=true -PenableCXXFrontend=true -PenableGoFrontend=true -PenablePythonFrontend=true -PenableLLVMFrontend=true -PenableTypeScriptFrontend=true -Pintegration spotlessCheck -x spotlessApply build -x distZip -x distTar
./gradlew --no-daemon --parallel -Pversion=$VERSION -Pintegration spotlessCheck -x spotlessApply build -x distZip -x distTar
fi
id: build
env:
VERSION: ${{ env.version }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare test and coverage reports
if: ${{ always() }}
run: |
zip reports.zip **/build/reports/**
- name: Archive test and coverage reports
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: reports
path: "**/build/reports"
path: reports.zip
- name: Download old dokka versions
run: |
# make sure the previousDocs folder exists
mkdir previousDocs && cd previousDocs
# retrieve the previous documentation folders for each published version (this also includes "main")
wget -O - https://github.com/Fraunhofer-AISEC/cpg/archive/gh-pages.tar.gz | tar -xz --strip=2 cpg-gh-pages/dokka
# in order to avoid duplicate mains, remove the "main" version from the previous versions
rm -rf main
- name: Publish
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')
run: |
Expand All @@ -155,7 +168,7 @@ jobs:
- name: Build JavaDoc
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha') || github.ref == 'refs/heads/main'
run: |
./gradlew --no-daemon --parallel -Pversion=$VERSION -PenableJavaFrontend=true -PenableCXXFrontend=true -PenableGoFrontend=true -PenablePythonFrontend=true -PenableLLVMFrontend=true -PenableTypeScriptFrontend=true dokkaHtmlMultiModule
./gradlew --no-daemon -Pversion=$VERSION dokkaHtmlMultiModule
- name: Publish JavaDoc (version)
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')
uses: JamesIves/github-pages-deploy-action@v4
Expand All @@ -168,7 +181,7 @@ jobs:
with:
folder: build/dokkaCustomMultiModuleOutput/main
target-folder: dokka/main
- name: "Create Release"
- name: Create Release
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')
id: create_release
uses: softprops/action-gh-release@v1
Expand Down
13 changes: 0 additions & 13 deletions buildSrc/src/main/kotlin/cpg.formatting-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ plugins {
tasks.withType<KotlinCompile> {
dependsOn("spotlessApply")
}
tasks.withType<JavaCompile> {
dependsOn("spotlessApply")
}

val headerWithStars = """/*
* Copyright (c) ${"$"}YEAR, Fraunhofer AISEC. All rights reserved.
Expand Down Expand Up @@ -92,16 +89,6 @@ val headerWithHashes = """#
"""

spotless {
java {
targetExclude(
fileTree(project.projectDir) {
include("build/generated-src/**")
}
)
googleJavaFormat("1.15.0")
licenseHeader(headerWithStars).yearSeparator(" - ")
}

kotlin {
ktfmt().kotlinlangStyle()
licenseHeader(headerWithStars).yearSeparator(" - ")
Expand Down
26 changes: 8 additions & 18 deletions cpg-language-typescript/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* \______/ \__| \______/
*
*/
import com.github.gradle.node.yarn.task.YarnTask
import com.github.gradle.node.npm.task.NpmTask

plugins {
id("cpg.frontend-conventions")
Expand All @@ -44,32 +44,22 @@ publishing {

node {
download.set(findProperty("nodeDownload")?.toString()?.toBoolean() ?: false)
version.set("16.4.2")
version.set("18")
nodeProjectDir.set(file("${project.projectDir.resolve("src/main/nodejs")}"))
}

val yarnInstall by tasks.registering(YarnTask::class) {
val npmBuild by tasks.registering(NpmTask::class) {
inputs.file("src/main/nodejs/package.json").withPathSensitivity(PathSensitivity.RELATIVE)
inputs.file("src/main/nodejs/yarn.lock").withPathSensitivity(PathSensitivity.RELATIVE)
outputs.dir("src/main/nodejs/node_modules")
outputs.cacheIf { true }

workingDir.set(file("src/main/nodejs"))
yarnCommand.set(listOf("install", "--ignore-optional"))
}

val yarnBuild by tasks.registering(YarnTask::class) {
inputs.file("src/main/nodejs/package.json").withPathSensitivity(PathSensitivity.RELATIVE)
inputs.file("src/main/nodejs/yarn.lock").withPathSensitivity(PathSensitivity.RELATIVE)
inputs.file("src/main/nodejs/package-lock.json").withPathSensitivity(PathSensitivity.RELATIVE)
inputs.dir("src/main/nodejs/src").withPathSensitivity(PathSensitivity.RELATIVE)
outputs.dir("build/resources/main/nodejs")
outputs.cacheIf { true }

workingDir.set(file("src/main/nodejs"))
yarnCommand.set(listOf("bundle"))

dependsOn(yarnInstall)
npmCommand.set(listOf("run", "bundle"))
dependsOn(tasks.getByName("npmInstall"))
}

tasks.processResources {
dependsOn(yarnBuild)
dependsOn(npmBuild)
}
Loading

0 comments on commit 708ab68

Please sign in to comment.