Skip to content

Examples Directory Test Run - main #576

Examples Directory Test Run - main

Examples Directory Test Run - main #576

name: Examples Directory Tests Run - VM
run-name: Examples Directory Test Run - ${{ github.ref_name }}
on:
schedule:
- cron: '0 3 * * 3' # every wednesday at 3 AM
branches: [ "main" ]
#push:
# branches: [ "workflow-tweaks" ]
workflow_dispatch:
jobs:
check-commits:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
name: Check latest commit
outputs:
recent_gmt_commit: ${{ steps.check_gmt_commits.outputs.should_run }}
recent_examples_commit: ${{ steps.check_examples_commits.outputs.should_run }}
steps:
- name: Initialize Energy Estimation
uses: green-coding-solutions/eco-ci-energy-estimation@main
with:
task: start-measurement
project: "Green Metrics Tool"
machine: "ubuntu-latest"
tags: "CI/CD,Example-Tests-Check-Commits"
gmt-api-token: ${{ secrets.GMT_API_TOKEN }}
electricitymaps-api-token: ${{ secrets.ELECTRICITYMAPS_TOKEN }}
- id: check_gmt_commits
uses: green-coding-solutions/eco-ci-activity-checker@main
with:
repo: 'green-coding-solutions/green-metrics-tool'
branch: 'main'
- id: check_examples_commits
uses: green-coding-solutions/eco-ci-activity-checker@main
with:
repo: 'green-coding-solutions/example-applications'
branch: 'main'
workflow-id: 45266619
- name: Energy Estimation - Get Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@main
with:
task: get-measurement
- name: Energy Estimation - End Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@main
with:
task: display-results
run-tests:
needs: check-commits
if: ${{ needs.check-commits.outputs.recent_examples_commit == 'true' || needs.check-commits.outputs.recent_gmt_commit == 'true' || github.event_name == 'workflow_dispatch'}}
runs-on: ubuntu-latest
steps:
- name: Initialize Energy Estimation
uses: green-coding-solutions/eco-ci-energy-estimation@main
with:
task: start-measurement
project: "Green Metrics Tool"
machine: "ubuntu-latest"
tags: "CI/CD,Example-Tests-Main"
gmt-api-token: ${{ secrets.GMT_API_TOKEN }}
electricitymaps-api-token: ${{ secrets.ELECTRICITYMAPS_TOKEN }}
- name: Checkout Examples Directory
uses: actions/checkout@v4
with:
path: examples-directory
- name: Checkout Green Metrics Tool
uses: actions/checkout@v4
with:
repository: green-coding-solutions/green-metrics-tool
submodules: 'true'
path: green-metrics-tool
ref: main
- name: Energy Estimation - Get Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@main
with:
task: get-measurement
label: setup
- name: 'Setup, Run, and Teardown Tests'
uses: green-coding-solutions/green-metrics-tool/.github/actions/gmt-pytest@main
with:
gmt-directory: './green-metrics-tool'
tests-command: 'pytest ../../examples-directory/test/smoke_test.py -k "test_all_directories"'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Energy Estimation - Get Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@main
with:
task: get-measurement
label: tests
- name: Energy Estimation - End Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@main
with:
task: display-results