Skip to content

Commit

Permalink
Split into multiple jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
smeyer198 committed Dec 11, 2024
1 parent 37f62e8 commit f172f13
Showing 1 changed file with 15 additions and 87 deletions.
102 changes: 15 additions & 87 deletions .github/workflows/performance_pre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ env:
JAVA_VERSION: 17

jobs:
performance-pre:
performance-android:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build and test Android Scanner
uses: ./.github/actions/scanner-android
Expand All @@ -44,102 +42,32 @@ jobs:
source-branch: gh-pages
current-results: android_history.txt
output-file: gh-pages-output/android_history.txt

- name: Generate HTML report
run: |
echo "<html><body><h1>Aggregated Test Results</h1><ul>" > gh-pages-output/index.html
cat gh-pages-output/android_history.txt | while read line; do
echo "${line}"
echo "<li>${line}</li>" >> gh-pages-output/index.html
done
echo "</ul></body></html>" >> gh-pages-output/index.html
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4

- name: Store Android performance
uses: actions/upload-artifact@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./gh-pages-output
name: android-performance
path: gh-pages-output/android_history.txt

performance-pre-2:
if: false
performance-report:
runs-on: ubuntu-latest
needs: performance-android
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
# Sets up Java version
- name: Set up Java ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
distribution: adopt
java-package: jdk
java-version: ${{ env.JAVA_VERSION }}
# Restores Maven dependencies
- name: Restore local Maven repository
uses: actions/cache@v4
ref: gh-pages

- name: Load performance files
uses: actions/download-artifact@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run maven command
run: mvn clean verify -DrunAnalysisTests
path: gh-pages-output
merge-multiple: true

- name: Create or update gh-pages-output directory
run: mkdir -p gh-pages-output

- name: Aggregate test results from multiple directories
run: |
total_time=0
for dir in CryptoAnalysis/shippable/testresults; do
if [ -d "$dir" ]; then
echo "Processing directory: $dir"
for file in "$dir"/*.txt; do
if [ -f "$file" ]; then
echo "Processing file: $file"
# Extract the time elapsed from each relevant line in the file and sum it up
file_time=$(grep -oP "Time elapsed: \K[\d\.]+" "$file" | awk '{sum += $1} END {print sum}')
if [ -n "$file_time" ]; then
echo "Time found: $file_time seconds"
total_time=$(echo "$total_time + $file_time" | bc)
else
echo "No time elapsed found in file: $file"
fi
else
echo "No files found in directory: $dir"
fi
done
else
echo "Directory does not exist: $dir"
fi
done
# Convert total time to minutes, seconds, and milliseconds
total_time_int=$(printf "%.0f" "$total_time")
minutes=$((total_time_int / 60))
seconds=$((total_time_int % 60))
milliseconds=$(printf "%.0f" "$(echo "($total_time - $total_time_int) * 1000" | bc)")

echo "Total Time Calculated: ${minutes}m ${seconds}s ${milliseconds}ms"
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
run_number=${{ github.run_number }}
echo "Run ${run_number}, ${timestamp}, Total Time: ${minutes}m ${seconds}s ${milliseconds}ms" >> gh-pages-output/current_history.txt

- name: Combine current and past history
run: |
git checkout gh-pages
if [ -f current_history.txt ]; then
echo "current history"
git checkout gh-pages current_history.txt
cat gh-pages-output/current_history.txt >> current_history.txt
mv current_history.txt gh-pages-output/current_history.txt
fi
- name: Generate HTML report
run: |
echo "<html><body><h1>Aggregated Test Results</h1><ul>" > gh-pages-output/index.html
cat gh-pages-output/current_history.txt | while read line; do
cat gh-pages-output/android_history.txt | while read line; do
echo "${line}"
echo "<li>${line}</li>" >> gh-pages-output/index.html
done
Expand Down

0 comments on commit f172f13

Please sign in to comment.