-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): migrates circleci to github actions
- Loading branch information
Showing
1 changed file
with
120 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
name: Build and Test | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: eclipse-temurin:17-jdk | ||
env: | ||
_JAVA_OPTIONS: "-Xmx3G -Xms2G" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- 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: 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: 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/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: workspace | ||
path: . | ||
- 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/ |