Skip to content

Commit

Permalink
Merge pull request #1 from green-coding-solutions/main
Browse files Browse the repository at this point in the history
master
  • Loading branch information
meslubi2021 authored Jul 30, 2024
2 parents 7b6122d + ff1d496 commit 8587b89
Show file tree
Hide file tree
Showing 19 changed files with 30,874 additions and 1,027 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/data-json-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,29 @@ on:
# Reason being that we pull our ML model and this could have changed in the meantime
- cron: '22 4 * * 6'
workflow_dispatch:

jobs:
test-data-output-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Initialize Energy Estimation
uses: ./
with:
task: start-measurement
json-output: true

- uses: actions/setup-node@v3
with:
node-version: '18'

- name: Sleep 2
run: |
sleep 2
- name: Node Setup Energy Measurment
id: data-node-setup
uses: ./
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/overhead_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: test-action

on:
workflow_dispatch:

permissions:
contents: read
actions: read
pull-requests: write

jobs:
test-action:
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
fail-fast: true
matrix:
os: [ubuntu-22.04, ubuntu-24.04, ubuntu-20.04]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Sleep step
run: sleep 2

- name: Filesystem
run: timeout 10s ls -alhR /usr/lib
continue-on-error: true


- name: Sleep 3
run: sleep 3

63 changes: 57 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,84 @@ permissions:

jobs:
test-action:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
fail-fast: true
matrix:
os: [ubuntu-22.04, ubuntu-24.04, ubuntu-20.04]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: API Base Debug
run: |
echo "Current API Base is" ${{ github.api_url }}
- name: Initialize Energy Estimation
uses: ./
with:
task: start-measurement
company-uuid: "20b269ce-cd67-4788-8614-030eaf5a0b47"
project-uuid: "00000000-E63D-43E9-9714-A4DE9464F3D8"
machine-uuid: "00000001-E63D-43E9-9714-A4DE9464F3D8"

- name: Wait before the next step
- name: Sleep step
run: sleep 2

- name: Dump ECO-CI CPU Step before
run: |
cat /tmp/eco-ci/cpu-util-step.txt
- name: Dump ECO-CI CPU before
run: |
cat /tmp/eco-ci/cpu-util-total.txt
- name: Test measurement 1
uses: ./
with:
task: get-measurement
label: "Sleep 3s"

- name: Wait before the next step
run: sleep 2
- name: Dump ECO-CI CPU Step actual processed
run: |
cat /tmp/eco-ci/cpu-util-temp.txt
- name: Dump ECO-CI Energy Step actual processed
run: |
cat /tmp/eco-ci/energy-step.txt
- name: Filesystem
run: timeout 10s ls -alhR /usr/lib
continue-on-error: true

- name: Test measurement 2
uses: ./
with:
task: get-measurement
label: "ls -alhR /usr/lib"

- name: Sleep 3
run: sleep 3

- name: Test measurement 2
uses: ./
with:
task: get-measurement
label: "Sleep #2"
label: "Sleep 3s"


- name: Dump ECO-CI CPU
run: |
cat /tmp/eco-ci/cpu-util-total.txt
- name: Dump ECO-CI Energy
run: |
cat /tmp/eco-ci/energy-total.txt
- name: Eco CI Energy Estimation
uses: ./
Expand Down
33 changes: 22 additions & 11 deletions .gitlab-ci.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,39 @@ image: ubuntu:22.04
include:
remote: 'https://raw.githubusercontent.com/green-coding-solutions/eco-ci-energy-estimation/main/eco-ci-gitlab.yml'

# trigger rebuild
stages:
- test

test-job:
stage: test

test-job: # This job runs in the test stage.
stage: test # It only starts when the job in the build stage completes successfully.
script:
# Please input valid UUIDs here if you want to use CarbonDB (https://www.green-coding.io/projects/carbondb/)
# Generate one here for example: https://www.freecodeformat.com/validate-uuid-guid.php
#- export ECO_CI_COMPANY_UUID="YOUR COMPANY UUID"
#- export ECO_CI_PROJECT_UUID="YOUR PROJECT UUID"
#- export ECO_CI_MACHINE_UUID="YOUR MACHINE UUID"

- apt-get update
- apt-get install git jq curl -y # git, jq and curl are a depedency for Eco-CI as we need to clone the gitlab repo

- !reference [.initialize_energy_estimator, script]
- !reference [.start_measurement, script]
- sleep 10s
- export ECO_CI_LABEL="measurement 1 (script)"
- sleep 2
- export ECO_CI_LABEL="Sleep 2"
- ls -alh /tmp/eco-ci
- echo "Step"
- cat /tmp/eco-ci/cpu-util-step.txt
- !reference [.get_measurement, script]
- sleep 3s
- export ECO_CI_LABEL="measurement 2 (script)"
- echo "Total"
- cat /tmp/eco-ci/cpu-util-total.txt
- echo "Energy"
- cat /tmp/eco-ci/energy-step.txt

- timeout 10s grep -R xxx / 1> /dev/null 2>/dev/null || true
- export ECO_CI_LABEL="grep with timeout"
- !reference [.get_measurement, script]
- export ECO_CI_SHOW_CARBON="true"
- !reference [.display_results, script]

artifacts:
paths:
- eco-ci-output.txt
- eco-ci-output.txt
- metrics.txt
Loading

0 comments on commit 8587b89

Please sign in to comment.