Skip to content

Commit

Permalink
ci: implement energy consumption check (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
pweimann committed Oct 31, 2024
1 parent 2d4860f commit 45b45d8
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
47 changes: 42 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: lpt-application-ui CI

on: [push]
on:
push:
workflow_call:
inputs:
upload:
default: false
required: false
type: boolean

permissions:
actions: read
Expand Down Expand Up @@ -85,8 +92,38 @@ jobs:
uses: green-coding-solutions/eco-ci-energy-estimation@v4
with:
task: display-results
- name: Store Baseline
uses: actions/upload-artifact@v3
- name: Get last successful baseline run ID
id: get-baseline
run: |
BASELINE_RUN_ID=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"repos/${{ github.repository }}/actions/workflows/energy-consumption-baseline.yaml/runs?per_page=1&status=success" \
--jq '.workflow_runs[0].id')
echo "baseline_run_id=${BASELINE_RUN_ID}" >> $GITHUB_OUTPUT
echo "used runId of the energy baseline run: ${BASELINE_RUN_ID}"
env:
GH_TOKEN: ${{ github.token }}
- name: test
run: |
echo "runId: ${{steps.get-baseline.outputs.baseline_run_id}}"
- name: Download Baseline Energy Consumption
uses: actions/download-artifact@v4
with:
name: energy-data
path: energy-data.json
github-token: ${{ github.token }}
repository: ${{ github.repository }}
run-id: ${{ steps.get-baseline.outputs.baseline_run_id }}
- name: Compare energy consumption
run: |
echo "Comparing energy consumption with baseline"
CURRENT_ENERGY=$(jq '.energy_joules' /tmp/eco-ci/total-data.json)
echo "Current energy consumption: ${CURRENT_ENERGY} joules"
- name: Upload energy data
if: inputs.upload == true
uses: actions/upload-artifact@v4
with:
name: energy-baseline
path: steps.data-total.outputs.data-total-json
name: energy-data
path: /tmp/eco-ci/total-data.json
retention-days: 10
15 changes: 15 additions & 0 deletions .github/workflows/energy-consumption-baseline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: store energy baseline

on:
# push:
workflow_dispatch:

permissions:
actions: read
contents: read

jobs:
call-ci:
uses: ./.github/workflows/ci.yaml
with:
upload: true

0 comments on commit 45b45d8

Please sign in to comment.