feat(ci): migrates circleci to github actions #9
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
name: Build and Test | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
container: | |
image: eclipse-temurin:17-jdk | |
env: | |
_JAVA_OPTIONS: "-Xmx3G -Xms2G" | |
steps: | |
- uses: actions/checkout@v2 | |
# - name: Set up JDK 17 | |
# uses: actions/setup-java@v3 | |
# with: | |
# distribution: 'temurin' | |
# java-version: '17' | |
- name: Install Node.js | |
run: | | |
curl -fsSL https://deb.nodesource.com/setup_21.x | bash - | |
apt-get install -y nodejs | |
- name: Check Node.js version | |
run: node --version | |
- name: Install Git | |
run: | | |
apt-get update && apt-get install -yqq git | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Setup | |
run: | | |
apt update -y && apt install -y gnupg2 | |
- name: Verify files | |
run: | | |
curl -sSL https://secchannel.rsk.co/SUPPORT.asc | gpg2 --import - | |
gpg2 --verify SHA256SUMS.asc && sha256sum --check SHA256SUMS.asc | |
- name: Build | |
run: | | |
./configure.sh | |
./gradlew --no-daemon dependencies | |
./gradlew --no-daemon --stacktrace build -x test | |
# - name: Persist workspace | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: workspace | |
# path: . | |
sonarqube: | |
needs: build | |
runs-on: ubuntu-latest | |
container: | |
image: eclipse-temurin:17-jdk | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Run SonarQube analysis | |
env: | |
SONAR_URL: ${{ secrets.SONAR_URL }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
apt-get update && apt-get install -yqq git | |
extra_flags="" | |
if [ "${{ github.event_name }}" == "pull_request" ]; then | |
git branch -f master origin/master | |
pr_number=${{ github.event.pull_request.number }} | |
extra_flags="-Dsonar.pullrequest.base=master | |
-Dsonar.pullrequest.branch=${{ github.head_ref }} | |
-Dsonar.pullrequest.key=$pr_number" | |
else | |
extra_flags="-Dsonar.branch.name=master" | |
fi | |
./gradlew sonarqube --no-daemon -x build -x test $extra_flags | |
unit-tests: | |
needs: build | |
runs-on: ubuntu-latest | |
container: | |
image: eclipse-temurin:17-jdk | |
steps: | |
- uses: actions/checkout@v2 | |
# - name: Set up JDK 17 | |
# uses: actions/setup-java@v3 | |
# with: | |
# distribution: 'temurin' | |
# java-version: '17' | |
- name: Install Node.js | |
run: | | |
curl -fsSL https://deb.nodesource.com/setup_21.x | bash - | |
apt-get install -y nodejs | |
- name: Check Node.js version | |
run: node --version | |
# | |
# - uses: actions/download-artifact@v3 | |
# with: | |
# name: workspace | |
# path: . | |
- name: Install Git | |
run: | | |
apt-get update && apt-get install -yqq git | |
# - uses: actions/cache@v3 | |
# with: | |
# path: | | |
# ~/.gradle/caches | |
# ~/.gradle/wrapper | |
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
# restore-keys: | | |
# ${{ runner.os }}-gradle- | |
- name: Run unit tests | |
run: | | |
./gradlew --no-daemon --stacktrace test | |
- name: Save test results | |
run: | | |
mkdir -p ${{ github.workspace }}/junit/ | |
find rskj-core/build/test-results -type f -name "*.xml" \ | |
-exec cp {} ${{ github.workspace }}/junit/ \; | |
if: always() | |
# | |
# - uses: actions/upload-artifact@v3 | |
# with: | |
# name: junit-results | |
# path: ${{ github.workspace }}/junit/ |