-
Notifications
You must be signed in to change notification settings - Fork 2
108 lines (92 loc) · 3.78 KB
/
examples-application-testing-vm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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 -vv -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