Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate energy measurements #1863

Merged
merged 33 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c563377
WIP - integrate energy measurements
Zeitsperre Aug 1, 2024
eefceaf
WIP - audit connections
Zeitsperre Aug 1, 2024
d9bae89
WIP - secure endpoints
Zeitsperre Aug 1, 2024
a9a6101
WIP - is coveralls service name required?
Zeitsperre Aug 1, 2024
eaa6289
Merge branch 'main' into energy-usage
Zeitsperre Aug 1, 2024
f772cfe
WIP - do not run metrics on Windows/macOS
Zeitsperre Aug 1, 2024
59f6934
Merge branch 'main' into energy-usage
Zeitsperre Aug 1, 2024
6039574
WIP - proper labelling
Zeitsperre Aug 1, 2024
ea3992a
allow sudo
Zeitsperre Aug 5, 2024
93d4345
add depedency review
Zeitsperre Aug 5, 2024
7a992f0
wip - audit
Zeitsperre Aug 5, 2024
ad07acc
Merge branch 'main' into energy-usage
Zeitsperre Aug 5, 2024
23f5981
fix commenting
Zeitsperre Aug 5, 2024
38f5b4a
wip - fix reporting
Zeitsperre Aug 5, 2024
5c5bc18
Merge branch 'main' into energy-usage
Zeitsperre Aug 5, 2024
ef8d010
wip - try testing branch
Zeitsperre Aug 6, 2024
f8a08fa
wip - use testing branch
Zeitsperre Aug 6, 2024
5cd24cd
update allowlist
Zeitsperre Aug 6, 2024
6a02078
Merge branch 'main' into energy-usage
Zeitsperre Aug 6, 2024
273d991
Merge branch 'main' into energy-usage
Zeitsperre Aug 6, 2024
f2256c7
Merge branch 'main' into energy-usage
Zeitsperre Aug 8, 2024
533c299
Merge branch 'main' into energy-usage
Zeitsperre Sep 19, 2024
606ba8c
Merge branch 'main' into energy-usage
Zeitsperre Nov 13, 2024
b768233
update energy measurement action version to latest
Zeitsperre Nov 13, 2024
9e4e6b5
add measurements to upstream.yml
Zeitsperre Nov 13, 2024
bb3cc81
handle race condition on teardown
Zeitsperre Nov 13, 2024
13a91cb
update CHANGELOG.rst
Zeitsperre Nov 15, 2024
67d72d7
Merge branch 'main' into energy-usage
Zeitsperre Nov 15, 2024
415ba6d
add pr comment
Zeitsperre Nov 15, 2024
2deb619
update permissions
Zeitsperre Nov 15, 2024
14e0cd0
remove pr comment, add badge
Zeitsperre Nov 15, 2024
770ccdd
fix URL
Zeitsperre Nov 15, 2024
e05cfb3
Merge branch 'main' into energy-usage
Zeitsperre Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,38 @@ jobs:
egress-policy: block
allowed-endpoints: >
api.deps.dev:443
api.electricitymap.org:443
api.github.com:443
api.green-coding.io:443
api.securityscorecards.dev:443
github.com:443
ip-api.com:80
ipapi.co:443
proxy.golang.org:443
pypi.org:443
sum.golang.org:443

- name: Start Energy Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: start-measurement
branch: ${{ github.head_ref || github.ref_name }}

- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Dependency Review
uses: actions/dependency-review-action@4081bf99e2866ebe428fc0477b69eb4fcda7220a # v4.4.0

- name: Energy Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: get-measurement
label: 'Dependency Review'
continue-on-error: true

- name: Show Energy Results
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: display-results
continue-on-error: true
183 changes: 158 additions & 25 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,22 @@ jobs:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.electricitymap.org:443
api.github.com:443
api.green-coding.io:443
files.pythonhosted.org:443
github.com:443
ip-api.com:80
ipapi.co:443
proxy.golang.org:443
pypi.org:443
sum.golang.org:443
- name: Start Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: start-measurement
branch: ${{ github.head_ref || github.ref_name }}
continue-on-error: true
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python3
Expand All @@ -58,6 +71,12 @@ jobs:
- name: Install CI libraries
run: |
python -m pip install --require-hashes -r CI/requirements_ci.txt
- name: Setup Python Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: get-measurement
label: 'Environment setup (Python${{ matrix.python-version }}, lint)'
continue-on-error: true
- name: Environment Caching
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
Expand All @@ -71,6 +90,17 @@ jobs:
- name: Run linting suite
run: |
python -m tox -e lint
- name: Tests measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: get-measurement
label: 'Lint (Python${{ matrix.python-version }})'
continue-on-error: true
- name: Show Energy Results
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: display-results
continue-on-error: true

test-preliminary:
name: Python${{ matrix.python-version }} (${{ matrix.os }})
Expand All @@ -88,12 +118,24 @@ jobs:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.electricitymap.org:443
api.github.com:443
dap.service.does.not.exist:443
api.green-coding.io:443
coveralls.io:443
files.pythonhosted.org:443
github.com:443
ip-api.com:80
ipapi.co:443
proxy.golang.org:443
pypi.org:443
raw.githubusercontent.com:443
sum.golang.org:443
- name: Start Energy Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: start-measurement
branch: ${{ github.head_ref || github.ref_name }}
continue-on-error: true
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python${{ matrix.python-version }}
Expand All @@ -104,6 +146,12 @@ jobs:
- name: Install CI libraries
run: |
python -m pip install --require-hashes -r CI/requirements_ci.txt
- name: Environment Setup Energy Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: get-measurement
label: 'Environment setup (Python${{ matrix.python-version }}, standard)'
continue-on-error: true
- name: Environment Caching
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
Expand All @@ -116,7 +164,19 @@ jobs:
python -m tox -- -m 'not slow'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-${{ matrix.python-version }}-ubuntu-latest-preliminary
COVERALLS_PARALLEL: true
- name: Tests measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: get-measurement
label: 'Testing with tox (Python${{ matrix.python-version }})'
continue-on-error: true
- name: Show Energy Results
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: display-results
continue-on-error: true

test-pypi:
needs: lint
Expand Down Expand Up @@ -180,18 +240,27 @@ jobs:
with:
egress-policy: block
allowed-endpoints: >
api.electricitymap.org:443
api.github.com:443
api.green-coding.io:443
azure.archive.ubuntu.com:80
coveralls.io:443
dap.service.does.not.exist:443
esm.ubuntu.com:443
files.pythonhosted.org:443
github.com:443
ip-api.com:80
ipapi.co:443
motd.ubuntu.com:443
packages.microsoft.com:443
ppa.launchpadcontent.net:443
proxy.golang.org:443
pypi.org:443
raw.githubusercontent.com:443
sum.golang.org:443
- name: Start Energy Measurement
if : ${{ matrix.os == 'ubuntu-latest' }}
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: start-measurement
branch: ${{ github.head_ref || github.ref_name }}
continue-on-error: true
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Eigen3 (SBCK)
Expand All @@ -207,6 +276,13 @@ jobs:
- name: Install CI libraries
run: |
python -m pip install --require-hashes -r CI/requirements_ci.txt
- name: Environment Setup Energy Measurement
if : ${{ matrix.os == 'ubuntu-latest' }}
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: get-measurement
label: 'Environment setup (Python${{ matrix.python-version }}, ${{ matrix.tox-env }})'
continue-on-error: true
- name: Environment Caching
# if prefetch is not in tox-env
if: contains(matrix.tox-env, 'prefetch') == false
Expand All @@ -232,6 +308,19 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.tox-env }}
COVERALLS_PARALLEL: true
- name: Tests measurement
if : ${{ matrix.os == 'ubuntu-latest' }}
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: get-measurement
label: 'Testing with tox (Python${{ matrix.python-version }}, ${{ matrix.tox-env }})'
continue-on-error: true
- name: Show Energy Results
if : ${{ matrix.os == 'ubuntu-latest' }}
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: display-results
continue-on-error: true

test-conda:
needs: lint
Expand All @@ -240,7 +329,7 @@ jobs:
contains(github.event.pull_request.labels.*.name, 'approved') ||
(github.event.review.state == 'approved') ||
(github.event_name == 'push')
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ 'ubuntu-latest' ]
Expand All @@ -256,16 +345,25 @@ jobs:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.electricitymap.org:443
api.github.com:443
conda.anaconda.org:443
api.green-coding.io:443
coveralls.io:443
dap.service.does.not.exist:443
files.pythonhosted.org:443
github.com:443
ip-api.com:80
ipapi.co:443
objects.githubusercontent.com:443
proxy.golang.org:443
pypi.org:443
raw.githubusercontent.com:443
repo.anaconda.com:443
sum.golang.org:443
- name: Start Energy Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: start-measurement
branch: ${{ github.head_ref || github.ref_name }}
continue-on-error: true
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Conda (Micromamba) with Python${{ matrix.python-version }}
Expand All @@ -276,9 +374,6 @@ jobs:
environment-file: environment.yml
create-args: >-
python=${{ matrix.python-version }}
- name: Micromamba version
run: |
echo "micromamba: $(micromamba --version)"
- name: Test Data Caching
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
Expand All @@ -293,42 +388,80 @@ jobs:
micromamba list
xclim show_version_info
python -m pip check || true
- name: Environment Setup Energy Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: get-measurement
label: 'Environment setup (conda, Python${{ matrix.python-version }})'
continue-on-error: true
- name: Test with pytest
run: |
python -m pytest --numprocesses=logical --durations=10 --cov=xclim --cov-report=term-missing
# - name: Install tox
# shell: bash -l {0}
# run: |
# mamba install -n xclim39 tox tox-conda
# - name: Test
# shell: bash -l {0}
# run: |
# conda activate xclim39
# tox -e opt-slow
# env:
# CONDA_EXE: mamba
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Report coverage
run: |
coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-{{ matrix.python-version }}-conda
COVERALLS_PARALLEL: true
- name: Tests measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: get-measurement
label: 'Testing with pytest (conda, Python${{ matrix.python-version }})'
continue-on-error: true
- name: Show Energy Results
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: display-results
continue-on-error: true

finish:
name: Finish
needs:
- test-preliminary
- test-pypi
- test-conda
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
disable-sudo: true
egress-policy: audit
egress-policy: block
allowed-endpoints: >
api.electricitymap.org:443
api.github.com:443
api.green-coding.io:443
coveralls.io:443
files.pythonhosted.org:443
github.com:443
ip-api.com:80
ipapi.co:443
objects.githubusercontent.com:443
proxy.golang.org:443
pypi.org:443
sum.golang.org:443
- name: Start Energy Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: start-measurement
branch: ${{ github.head_ref || github.ref_name }}
continue-on-error: true
- name: Coveralls Finished
uses: coverallsapp/github-action@cfd0633edbd2411b532b808ba7a8b5e04f76d2c8 # v2.3.4
with:
parallel-finished: true
- name: Finish measurement
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: get-measurement
label: 'Finish Run'
continue-on-error: true
- name: Show Energy Results
uses: green-coding-solutions/eco-ci-energy-estimation@86f1b2ee12db687bca0d15160a529bb64a7b60d9 # v4.0.0
with:
task: display-results
continue-on-error: true
8 changes: 4 additions & 4 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ jobs:
egress-policy: audit

- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Run Analysis
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -59,14 +59,14 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: Upload Artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: Upload to code-scanning
uses: github/codeql-action/upload-sarif@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # 3.23.0
uses: github/codeql-action/upload-sarif@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # 3.23.0
with:
sarif_file: results.sarif
Loading
Loading