feat: use HashSet to improve the performance #137
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: Run Plot Action and Upload Results | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
plot-and-publish: | |
runs-on: ubuntu-latest | |
if: "github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, 'release-please--branches--main')" | |
steps: | |
- name: ⬇️ Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup JDK 18 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '18' | |
distribution: 'temurin' | |
cache: maven | |
- name: Setup dependencies | |
run: | | |
pip install yq | |
- name: ⬇️ Download test data | |
uses: keithweaver/[email protected] | |
with: | |
command: cp | |
source: ${{ secrets.AWS_S3_BUCKET }} | |
destination: ./rewards-calculation-test-data | |
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws_region: ${{ secrets.AWS_REGION }} | |
flags: --recursive | |
- name: 🍀 Generate .env file | |
run: | | |
echo "SPRING_PROFILES_ACTIVE=ci" >> src/main/resources/.env | |
echo "RUN_MODE=plot" >> src/main/resources/.env | |
echo "OVERWRITE_EXISTING_DATA=false" >> src/main/resources/.env | |
echo "JSON_DATA_SOURCE_FOLDER=./rewards-calculation-test-data" >> src/main/resources/.env | |
- name: Build | |
run: | | |
mvn --batch-mode --update-snapshots clean package -DskipTests && mv target/rewards-*.jar target/rewards-calculation.jar | |
- name: 📊 Generate plots | |
run: java -jar target/rewards-calculation.jar | |
- name: JSON result to js file | |
run: | | |
echo -e "const treasuryCalculationResult = $(cat ./report/treasury_calculation_result.json)" > ./report/treasury_calculation_result.js | |
- name: 👀 Lookup metadata for report | |
run: | | |
echo "VERSION=$(xq -r .project.version pom.xml)" >> $GITHUB_ENV | |
echo "LATEST_COMMIT_HASH=$(git rev-parse "$GITHUB_SHA")" >> $GITHUB_ENV | |
echo "LATEST_COMMIT_HASH_SHORT=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV | |
echo "UTC_DATE=$(date -uR|sed 's/.....$//')" >> $GITHUB_ENV | |
- name: 📂 Create report directory | |
run: | | |
mkdir -p report-v${{ env.VERSION }} | |
- name: 📄 Copy report files | |
run: | | |
cp -r report/* report-v${{ env.VERSION }} | |
- name: 📝 Add metadata to the report | |
run: | | |
sed -i 's|<footer></footer>|<footer><p>Created on ${{ env.UTC_DATE }} UTC as a result of modifications triggered by <a href="https://github.com/cardano-foundation/cf-java-rewards-calculation/commit/${{ env.LATEST_COMMIT_HASH }}">${{ env.LATEST_COMMIT_HASH_SHORT }}</a></p></footer>|' report-v${{ env.VERSION }}/treasury_calculation.html | |
- name: 📅 Publish report to gh-pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
BRANCH: gh-pages | |
folder: report-v${{ env.VERSION }} | |
target-folder: report-latest/ | |
- name: 📅 Publish report to gh-pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
BRANCH: gh-pages | |
folder: report-v${{ env.VERSION }} | |
target-folder: report-v${{ env.VERSION }}/ |