tests #3961
This file contains 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
# Workflow for testing Sorald. | |
# | |
# Note that actions are specified by commit hash. This is to avoid the security | |
# risk of someone injecting malicious code into a release and then simply | |
# changing a tag. | |
name: tests | |
on: | |
pull_request: | |
push: | |
branches: master | |
schedule: | |
- cron: "0 0 * * *" | |
env: | |
JAVA_DISTRIBUTION: 'adopt' | |
jobs: | |
build-and-test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, macos-latest, windows-latest ] | |
steps: | |
- name: Disable Git's autocrlf on Windows | |
if: ${{ matrix.os == 'windows-latest' }} | |
run: git config --global core.autocrlf false | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 # SonarCloud prefers non-shallow clones | |
- uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0 | |
with: | |
java-version: 11 | |
java-package: jdk | |
architecture: x64 | |
distribution: ${{ env.JAVA_DISTRIBUTION }} | |
- name: Get date for cache # see https://github.com/actions/cache README | |
id: get-date | |
run: echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")" | |
shell: bash | |
- name: Use Maven dependency cache | |
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: Use SonarCloud package cache | |
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Check formatting with spotless | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: mvn spotless:check | |
- name: Build project | |
run: mvn -B install -DskipTests | |
- name: Fetch final dependencies | |
# this is a hack to fetch some test runtime dependencies | |
run: timeout 10 mvn -B test || echo "Done fetching dependencies" | |
shell: bash | |
- name: Run unit tests and integration tests | |
run: mvn -B verify | |
- name: Test memory-constrained execution with segment repair | |
shell: bash | |
run: .github/mem-constrained-exec.sh | |
- name: Upload coverage report to Codecov | |
uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 | |
test-support-scripts: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa # v4.8.0 | |
with: | |
python-version: '3.10.12' | |
update-environment: false | |
- uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0 | |
with: | |
java-version: 11 | |
java-package: jdk | |
architecture: x64 | |
distribution: ${{ env.JAVA_DISTRIBUTION }} | |
- name: Get date for cache # see https://github.com/actions/cache README | |
id: get-date | |
run: echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")" | |
shell: bash | |
- name: Use Maven dependency cache | |
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: Package Sorald | |
run: mvn package -DskipTests | |
- name: Test support scripts | |
run: | | |
cd experimentation/tools | |
pip install --upgrade pip | |
pip install -e .[TEST] | |
pytest tests/ | |
test-code-generation: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0 | |
with: | |
java-version: 11 | |
java-package: jdk | |
architecture: x64 | |
distribution: ${{ env.JAVA_DISTRIBUTION }} | |
- name: Get date for cache # see https://github.com/actions/cache README | |
id: get-date | |
run: echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")" | |
shell: bash | |
- name: Use Maven dependency cache | |
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: Test that generated code is up-to-date | |
run: | | |
mvn install -DskipTests | |
mvn clean compile dependency:build-classpath -Dmdep.outputFile=cp.txt | |
(cd sorald && java -cp "$(cat cp.txt):target/classes" sorald.CodeGenerator) | |
mvn spotless:apply | |
git diff --exit-code |