| # Licensed to the Apache Software Foundation (ASF) under one or more |
| # contributor license agreements. See the NOTICE file distributed with |
| # this work for additional information regarding copyright ownership. |
| # The ASF licenses this file to You under the Apache License, Version 2.0 |
| # (the "License"); you may not use this file except in compliance with |
| # the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| name: CI |
| |
| # Run CI when pushing a commit to main or creating a pull request or |
| # adding another commit to a pull request or reopening a pull request. |
| |
| on: |
| push: |
| branches-ignore: [ 'dependabot/**' ] |
| pull_request: |
| types: [ opened, synchronize, reopened ] |
| |
| # Cancel CI runs in progress when a pull request is updated. |
| concurrency: |
| group: ${{ github.head_ref || ((github.ref_name != 'main' && github.ref_name) || github.run_id) }}-${{ github.workflow }} |
| cancel-in-progress: true |
| |
| jobs: |
| |
| # Build Daffodil and run some checks. |
| |
| check: |
| name: Java ${{ matrix.java_version }}, Scala ${{ matrix.scala_version }}, ${{ matrix.os }} |
| strategy: |
| fail-fast: false |
| max-parallel: 7 |
| matrix: |
| java_distribution: [ temurin ] |
| java_version: [ 17, 21, 25 ] |
| scala_version: [ 3.3.7 ] |
| os: [ ubuntu-22.04, windows-2022, macos-14 ] |
| exclude: |
| # only run macos on java 17 |
| - os: macos-14 |
| java_version: 21 |
| - os: macos-14 |
| java_version: 25 |
| include: |
| # configure shell/cc/ar for all OSes |
| - os: ubuntu-22.04 |
| shell: bash |
| env_cc: clang |
| env_ar: llvm-ar-14 |
| - os: windows-2022 |
| shell: msys2 {0} |
| env_cc: clang |
| env_ar: llvm-ar |
| - os: macos-14 |
| shell: bash |
| env_cc: cc |
| env_ar: ar |
| # configure different languages/encodings for some jobs, defaulting to en_US/UTF-8 |
| - lang: en_US |
| - encoding: UTF-8 |
| - os: ubuntu-22.04 |
| java_version: 17 |
| lang: de_DE |
| - os: ubuntu-22.04 |
| java_version: 21 |
| lang: ja_JP |
| - os: windows-2022 |
| java_version: 21 |
| encoding: US-ASCII |
| |
| |
| runs-on: ${{ matrix.os }} |
| defaults: |
| run: |
| shell: ${{ matrix.shell }} |
| env: |
| AR: ${{ matrix.env_ar }} |
| CC: ${{ matrix.env_cc }} |
| LANG: ${{ matrix.lang }}.${{ matrix.encoding }} |
| SBT: sbt -J-Xms1024m -J-Xmx5120m -J-XX:ReservedCodeCacheSize=512m -J-XX:MaxMetaspaceSize=1024m -J-Dfile.encoding=${{ matrix.encoding }} ++${{ matrix.scala_version }} coverage |
| SONARSCAN: ${{ |
| matrix.os == 'ubuntu-22.04' && |
| matrix.java_version == '17' && |
| matrix.scala_version == '3.3.7' && |
| github.event_name == 'push' && |
| github.repository == 'apache/daffodil' && |
| github.ref == 'refs/heads/main' |
| }} |
| DAFFODIL_TDML_API_INFOSETS: all |
| |
| steps: |
| |
| ############################################################ |
| # Setup |
| ############################################################ |
| |
| - name: Install Dependencies (macOS) |
| if: runner.os == 'macOS' |
| run: brew install sbt |
| |
| - name: Check out mxml source (macOS) |
| if: runner.os == 'macOS' |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| with: |
| repository: michaelrsweet/mxml |
| ref: v3.3.1 |
| path: mxml |
| |
| - name: Install mxml library (macOS) |
| if: runner.os == 'macOS' |
| run: | |
| cd mxml |
| ./configure |
| sudo make install |
| |
| - name: Install Dependencies (Linux) |
| if: runner.os == 'Linux' |
| run: | |
| sudo apt-get install -y libmxml-dev |
| sudo locale-gen $LANG |
| |
| - name: Install Dependencies (Windows) |
| if: runner.os == 'Windows' |
| uses: msys2/setup-msys2@4f806de0a5a7294ffabaff804b38a9b435a73bda # v2.30.0 |
| with: |
| install: clang diffutils make pkgconf |
| path-type: inherit |
| |
| - name: Check out mxml source (Windows) |
| if: runner.os == 'Windows' |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| with: |
| repository: michaelrsweet/mxml |
| ref: v3.3 |
| path: mxml |
| |
| - name: Install mxml library (Windows) |
| if: runner.os == 'Windows' |
| run: | |
| # Our codegen-c tests may break if mxml library is compiled with clang |
| export AR=ar CC=cc |
| cd mxml |
| ./configure --prefix=/usr --disable-shared --disable-threads |
| make install |
| # Workaround for sbt hanging problem |
| echo "COURSIER_CACHE=$temp" >> $GITHUB_ENV |
| echo "COURSIER_CONFIG_DIR=$temp" >> $GITHUB_ENV |
| |
| - name: Check out Repository |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| # Disabling shallow clone is recommended for improving sonarcloud reporting |
| with: |
| fetch-depth: 0 |
| |
| - name: Setup Java |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 |
| with: |
| distribution: ${{ matrix.java_distribution }} |
| java-version: ${{ matrix.java_version }} |
| cache: sbt |
| |
| # Cache Action - tried on 2021-06-28, removed because it didn't help |
| # 1. Tried coursier/cache-action but Apache didn't allow it |
| # extraSbtFiles: daffodil-cli/build.sbt daffodil-japi/build.sbt |
| # 2. Tried actions/cache but it didn't speed up CI at all |
| # path: ~/.cache/coursier ~/.ivy2/cache ~/.sbt |
| |
| ############################################################ |
| # Build & Package |
| ############################################################ |
| |
| - name: Compile |
| run: $SBT compile Test/compile daffodil-test-integration/Test/compile |
| |
| - name: Build Documentation |
| run: $SBT unidoc genTunablesDoc |
| |
| - name: Package Zip |
| run: $SBT daffodil-cli/Universal/packageBin |
| |
| - name: Package RPM & Tar (Linux) |
| if: runner.os == 'Linux' |
| run: $SBT daffodil-cli/Rpm/packageBin daffodil-cli/Universal/packageZipTarball |
| |
| ############################################################ |
| # Check |
| ############################################################ |
| |
| - name: Run Unit Tests |
| run: $SBT test |
| |
| - name: Run Integration Tests |
| run: $SBT daffodil-test-integration/test |
| |
| - name: Run Modified Example Files Check |
| run: git diff --color --exit-code |
| |
| - name: Generate Coverage Report |
| run: $SBT coverageAggregate |
| |
| - name: Upload Coverage Report |
| uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 |
| with: |
| token: ${{ secrets.CODECOV_TOKEN }} |
| |
| - name: Prepare for SonarCloud Scan |
| if: ${{ env.SONARSCAN == 'true' }} |
| run: | |
| SONAR_SCALA_VERSION=${{ matrix.scala_version }} |
| JAVA_JARS=$(sbt -batch -no-colors -error "export Compile/dependencyClasspath" 2>/dev/null) |
| TEST_JAVA_JARS=$(sbt -batch -no-colors -error "export Test/dependencyClasspath" 2>/dev/null) |
| SONAR_JAVA_JARS=$(echo "$JAVA_JARS" | grep -v dependencyClasspath | tr ':;' '\n'| sort -u | paste -sd ',' -) |
| SONAR_TEST_JAVA_JARS=$(echo "$TEST_JAVA_JARS" | grep -v dependencyClasspath | tr ':;' '\n'| sort -u | paste -sd ',' -) |
| # NOTE: This is needed by .sonar-project.properties so it can |
| # have the right reportPath per version, as well as the proper |
| # path to jar dependencies |
| echo "SONAR_SCALA_VERSION=$SONAR_SCALA_VERSION" >> $GITHUB_ENV |
| echo "SONAR_JAVA_JARS=$SONAR_JAVA_JARS" >> $GITHUB_ENV |
| echo "SONAR_TEST_JAVA_JARS=$SONAR_TEST_JAVA_JARS" >> $GITHUB_ENV |
| $SBT coverageReport |
| |
| - name: Run SonarCloud Scan |
| if: ${{ env.SONARSCAN == 'true' }} |
| uses: SonarSource/sonarqube-scan-action@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9 # v7.0.0 |
| env: |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| with: |
| args: -Dproject.settings=.sonar-project.properties |
| |
| |
| # Lint checks that do not require compilation |
| lint: |
| name: Lint Checks |
| strategy: |
| fail-fast: false |
| max-parallel: 1 |
| matrix: |
| java_distribution: [ temurin ] |
| java_version: [ 17 ] |
| scala_version: [ 3.3.7 ] |
| os: [ ubuntu-22.04 ] |
| runs-on: ${{ matrix.os }} |
| env: |
| SBT: sbt -J-Xms1024m -J-Xmx5120m -J-XX:ReservedCodeCacheSize=512m -J-XX:MaxMetaspaceSize=1024m ++${{ matrix.scala_version }} |
| steps: |
| |
| ############################################################ |
| # Setup |
| ############################################################ |
| |
| - name: Check out Repository |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| |
| - name: Setup Java |
| uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 |
| with: |
| distribution: ${{ matrix.java_distribution }} |
| java-version: ${{ matrix.java_version }} |
| cache: sbt |
| |
| ############################################################ |
| # Lint checks |
| ############################################################ |
| |
| - name: Run Rat Check |
| if: success() || failure() |
| run: $SBT ratCheck || (cat target/rat.txt; exit 1) |
| |
| - name: Run OSGI Check |
| if: success() || failure() |
| run: $SBT osgiCheck |
| |
| - name: Run scalafmt Check |
| if: success() || failure() |
| run: $SBT scalafmtCheckAll scalafmtSbtCheck daffodil-test-integration/scalafmtCheckAll |
| |
| |
| # Ensure pull requests only have a single commit |
| single-commit: |
| name: Single Commit Pull Request |
| if: github.event_name == 'pull_request' |
| runs-on: ubuntu-22.04 |
| steps: |
| - name: Check Single Commit |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 |
| with: |
| script: | |
| const commits = await github.rest.pulls.listCommits({ |
| ...context.repo, |
| pull_number: context.issue.number, |
| }); |
| core.info("Number of commits in this pull request: " + commits.data.length); |
| if (commits.data.length > 1) { |
| core.setFailed("If approved with two +1's, squash this pull request into one commit"); |
| } |