Add standardized Sourcegraph CI (build checks + code intel) #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: SG CI - Java | |
| on: | |
| push: | |
| pull_request: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| - name: Build | |
| run: | | |
| if [ -f pom.xml ]; then mvn -B -e -DskipTests compile; | |
| elif [ -f build.gradle ] || [ -f build.gradle.kts ]; then chmod +x ./gradlew 2>/dev/null || true; ./gradlew compileJava -x test || gradle compileJava -x test; | |
| else | |
| # No build system: this is a loose collection of independent .java files | |
| # (e.g. a code-search corpus). Such files come from different projects, | |
| # reference unvendored third-party dependencies, reuse class names, and do | |
| # not share a package/filename convention, so they cannot be compiled as a | |
| # single unit. Run javac as a best-effort syntax check without failing the job. | |
| find . -name '*.java' > /tmp/srcs.txt; mkdir -p /tmp/out; | |
| javac -d /tmp/out @/tmp/srcs.txt || echo "Best-effort javac completed with errors (loose snippet corpus, no build system); not failing the build."; | |
| fi | |
| code-intel: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| - name: Install scip-java and src-cli | |
| run: | | |
| curl -sfLo /usr/local/bin/cs https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux | |
| chmod +x /usr/local/bin/cs | |
| cs install --quiet scip-java || true | |
| curl -sfL https://demo.sourcegraph.com/.api/src-cli/src_linux_amd64 -o /usr/local/bin/src | |
| chmod +x /usr/local/bin/src | |
| - name: Index and upload | |
| env: | |
| SRC_ENDPOINT: https://demo.sourcegraph.com | |
| SRC_ACCESS_TOKEN: ${{secrets.SRC_ACCESS_TOKEN}} | |
| run: | | |
| export PATH="$HOME/.local/share/coursier/bin:$PATH" | |
| if [ -f pom.xml ] || [ -f build.gradle ] || [ -f build.gradle.kts ]; then scip-java index || true; fi | |
| if [ -f index.scip ]; then src code-intel upload -no-progress; else echo "no index (needs a build tool)"; fi |