| # 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 master 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] |
| |
| jobs: |
| |
| # Build Daffodil and run some checks. |
| |
| check: |
| name: Java ${{ matrix.java_version }}, Scala ${{ matrix.scala_version }}, ${{ matrix.os }} |
| strategy: |
| fail-fast: false |
| matrix: |
| distribution: [ adopt ] |
| java_version: [ 8, 11, 16 ] |
| scala_version: [ 2.12.14 ] |
| os: [ ubuntu-20.04, windows-2019 ] |
| include: |
| - os: ubuntu-20.04 |
| shell: bash |
| env_cc: clang-10 |
| env_ar: llvm-ar-10 |
| - os: windows-2019 |
| shell: msys2 {0} |
| env_cc: clang |
| env_ar: llvm-ar |
| |
| runs-on: ${{ matrix.os }} |
| defaults: |
| run: |
| shell: ${{ matrix.shell }} |
| env: |
| AR: ${{ matrix.env_ar }} |
| CC: ${{ matrix.env_cc }} |
| SBT: sbt -J-Xms1024m -J-Xmx5120m -J-XX:ReservedCodeCacheSize=512m -J-XX:MaxMetaspaceSize=1024m ++${{ matrix.scala_version }} |
| SONARSCAN: ${{ |
| matrix.os == 'ubuntu-20.04' && |
| matrix.java_version == '11' && |
| matrix.scala_version == '2.12.14' && |
| github.event_name == 'push' && |
| github.repository == 'apache/daffodil' && |
| github.ref == 'refs/heads/master' |
| }} |
| |
| steps: |
| |
| ############################################################ |
| # Setup |
| ############################################################ |
| |
| - name: Install Dependencies (Linux) |
| if: runner.os == 'Linux' |
| run: sudo apt-get install -y libmxml-dev |
| |
| - name: Install Dependencies (Windows) |
| if: runner.os == 'Windows' |
| uses: msys2/setup-msys2@v2 |
| with: |
| install: clang diffutils make pkgconf |
| path-type: inherit |
| |
| - name: Check out mxml source (Windows) |
| if: runner.os == 'Windows' |
| uses: actions/checkout@v2.3.4 |
| with: |
| repository: michaelrsweet/mxml |
| ref: v3.2 |
| path: mxml |
| |
| - name: Install mxml library (Windows) |
| if: runner.os == 'Windows' |
| run: | |
| # Our runtime2 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: Setup Java |
| uses: actions/setup-java@v2.1.0 |
| with: |
| distribution: ${{ matrix.distribution }} |
| java-version: ${{ matrix.java_version }} |
| |
| # 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 |
| |
| - name: Check out Repository |
| uses: actions/checkout@v2.3.4 |
| # Disabling shallow clone is recommended for improving reporting |
| with: |
| fetch-depth: 0 |
| |
| ############################################################ |
| # Build & Package |
| ############################################################ |
| |
| - name: Compile |
| run: $SBT coverage compile Test/compile IntegrationTest/compile |
| |
| - name: Build Documentation |
| run: $SBT unidoc |
| |
| - name: Package Zip & Tar |
| run: $SBT daffodil-cli/Universal/packageBin daffodil-cli/Universal/packageZipTarball |
| |
| - name: Package RPM (Linux) |
| if: runner.os == 'Linux' |
| run: $SBT daffodil-cli/Rpm/packageBin |
| |
| ############################################################ |
| # Check |
| ############################################################ |
| |
| - name: Run Rat Check |
| run: $SBT ratCheck || (cat target/rat.txt; exit 1) |
| |
| - name: Run Unit Tests |
| run: $SBT coverage test |
| |
| - name: Run Integration Tests |
| run: $SBT coverage IntegrationTest/test |
| |
| - name: Generate Coverage Report |
| run: $SBT coverageAggregate |
| |
| - name: Upload Coverage Report |
| uses: codecov/codecov-action@v2.0.2 |
| |
| - name: Prepare for SonarCloud Scan |
| if: ${{ env.SONARSCAN == 'true' }} |
| run: | |
| $SBT coverageReport |
| find . -name scoverage.xml -exec sed -i 's#/home/runner/work/daffodil/daffodil#/github/workspace#g' {} + |
| |
| - name: Run SonarCloud Scan |
| if: ${{ env.SONARSCAN == 'true' }} |
| uses: sonarsource/sonarcloud-github-action@v1.6 |
| env: |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| with: |
| args: -Dproject.settings=.sonar-project.properties |
| |
| |
| # Ensure pull requests only have a single commit |
| |
| single-commit: |
| name: Single Commit Pull Request |
| if: github.event_name == 'pull_request' |
| runs-on: ubuntu-20.04 |
| steps: |
| - name: Check Single Commit |
| uses: actions/github-script@v4.0.2 |
| with: |
| script: | |
| const commits = await github.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"); |
| } |