Skip to content

Examples Directory Test Run - main #582

Examples Directory Test Run - main

Examples Directory Test Run - main #582

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
# Actions checkout@v4 flakes as the repo contains non-resolving symlinks for the EE version
- name: Checkout Green Metrics Tool
run: |
git clone https://github.com/green-coding-solutions/green-metrics-tool
- name: Energy Estimation - Get Measurement
uses: green-coding-solutions/eco-ci-energy-estimation@main
with:
task: get-measurement
label: setup
# we have to load the action manually, as when we link directly with "uses: ./.github/actions/gmt-pytest"
# GitHub flakes as it somehow chokes on the symlinks in the general green-metrics-tool repository
- name: 'Setup, Run, and Teardown Tests'
uses: ./green-metrics-tool/.github/actions/gmt-pytest
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