-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into alwhr/move-contracts-to-measurements
- Loading branch information
Showing
9 changed files
with
254 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Copyright 2020 Energinet DataHub A/S | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License2"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: CD | ||
|
||
on: | ||
workflow_dispatch: {} | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
# | ||
# Detect changes to start relevant jobs | ||
# | ||
|
||
changes: | ||
uses: ./.github/workflows/detect-changes.yml | ||
|
||
# | ||
# CD Databricks | ||
# | ||
|
||
electrical_heating: | ||
needs: changes | ||
if: ${{ needs.changes.outputs.electrical_heating == 'true' }} | ||
uses: Energinet-DataHub/.github/.github/workflows/promote-prerelease.yml@v14 | ||
with: | ||
release_name_prefix: electrical_heating | ||
|
||
# | ||
# Dispatch deployment request | ||
# | ||
|
||
dispatch_deploment_event: | ||
if: ${{ always() && !cancelled() && !failure() && needs.changes.outputs.electrical_heating == 'true' }} | ||
runs-on: ubuntu-latest | ||
needs: [ | ||
changes, | ||
electrical_heating | ||
] | ||
steps: | ||
- run: echo "${{ toJSON(needs) }}" | ||
|
||
- name: Find associated pull request | ||
uses: Energinet-DataHub/.github/.github/actions/find-related-pr-number@v14 | ||
id: find_pull_request | ||
|
||
- uses: Energinet-DataHub/.github/.github/actions/github-create-token@v14 | ||
name: Generate Github token | ||
id: generate_token | ||
with: | ||
app_id: ${{ vars.dh3serviceaccount_appid }} | ||
private_key: ${{ secrets.dh3serviceaccount_privatekey }} | ||
|
||
- name: Repository Dispatch | ||
uses: peter-evans/repository-dispatch@v3 | ||
with: | ||
token: ${{ steps.generate_token.outputs.token }} | ||
repository: ${{ vars.environment_repository_path }} | ||
event-type: measurements-deployment-request-domain | ||
# yamllint disable-line rule:quoted-strings | ||
client-payload: '{"pr_number": "${{ steps.find_pull_request.outputs.pull_request_number }}", "electrical_heating": "${{ needs.changes.outputs.electrical_heating }}"}' | ||
|
||
# | ||
# Send notification to teams channel if deployment dispatch failed | ||
# | ||
|
||
dispatch_failed: | ||
needs: | ||
[ | ||
electrical_heating, | ||
dispatch_deploment_event | ||
] | ||
if: | | ||
always() && | ||
contains(needs.*.result, 'failure') | ||
uses: Energinet-DataHub/.github/.github/workflows/notify-team.yml@v14 | ||
with: | ||
team_name: Mandalorian | ||
subject: "Deployment dispatch failed: Measurements" | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: CI Electrical Heating | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
databricks_ci_build: | ||
uses: Energinet-DataHub/.github/.github/workflows/databricks-build-prerelease.yml@v14 | ||
with: | ||
python_version: 3.11.7 | ||
architecture: x64 | ||
wheel_working_directory: ./source/electrical_heating | ||
prerelease_prefix: electrical_heating | ||
|
||
mypy_check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.x | ||
- name: Run pip install and mypy check of files in package | ||
shell: bash | ||
run: | | ||
pip install --upgrade pip | ||
pip install mypy types-python-dateutil | ||
mypy ./source/electrical_heating --disallow-untyped-defs --ignore-missing-imports | ||
black_check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: psf/black@stable | ||
with: | ||
options: --check --diff | ||
src: ./source/electrical_heating |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Detect changes | ||
|
||
# DESCRIPTION: | ||
# This workflow will determine which categories of jobs should be executed, | ||
# based on detected changes. | ||
# It should be used by the 'ci-orchestrator.yml' and 'cd.yml' to ensure they both use | ||
# the same path's to detect changes. | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
electrical_heating: | ||
value: ${{ jobs.changes.outputs.electrical_heating }} | ||
|
||
jobs: | ||
changes: | ||
name: Determine relevant jobs | ||
runs-on: ubuntu-latest | ||
# Set job outputs to values from filter step | ||
outputs: | ||
electrical_heating: ${{ steps.filter.outputs.electrical_heating }} | ||
steps: | ||
# For pull requests it's not necessary to checkout the code because GitHub REST API is used to determine changes | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Detect file changes | ||
uses: dorny/paths-filter@v3 | ||
id: filter | ||
with: | ||
filters: | | ||
electrical_heating: | ||
- 'source/electrical_heating/**' | ||
- '.github/workflows/ci-electrical-heating.yml' |
Empty file.
3 changes: 1 addition & 2 deletions
3
source/electrical_heating/electrical_heating_job/entry_point.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
| ||
def execute() -> None: | ||
def execute() -> None: | ||
""" | ||
Entry point for the electrical heating job. | ||
""" | ||
|
10 changes: 10 additions & 0 deletions
10
...lectrical_heating/electrical_heating_job/entry_points/job_args/electrical_heating_args.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class ElectricalHeatingArgs: | ||
""" | ||
Args for the electrical heating job. | ||
""" | ||
|
||
electrical_heating_id: str |
43 changes: 43 additions & 0 deletions
43
...rical_heating/electrical_heating_job/entry_points/job_args/electrical_heating_job_args.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import argparse | ||
import sys | ||
import configargparse | ||
from argparse import Namespace | ||
from telemetry_logging import Logger, logging_configuration | ||
|
||
from .electrical_heating_args import ElectricalHeatingArgs | ||
|
||
|
||
def parse_command_line_arguments() -> Namespace: | ||
return _parse_args_or_throw(sys.argv[1:]) | ||
|
||
|
||
def parse_job_arguments( | ||
job_args: Namespace, | ||
) -> ElectricalHeatingArgs: | ||
logger = Logger(__name__) | ||
logger.info(f"Command line arguments: {repr(job_args)}") | ||
|
||
with logging_configuration.start_span("electrical_heating.parse_job_arguments"): | ||
|
||
electrical_heating_args = ElectricalHeatingArgs( | ||
electrical_heating_id=job_args.electrical_heating_id, | ||
) | ||
|
||
return electrical_heating_args | ||
|
||
|
||
def _parse_args_or_throw(command_line_args: list[str]) -> argparse.Namespace: | ||
p = configargparse.ArgParser( | ||
description="Execute electrical heating calculation", | ||
formatter_class=configargparse.ArgumentDefaultsHelpFormatter, | ||
) | ||
|
||
# Run parameters | ||
p.add_argument("--electrical-heating-id", type=str, required=True) | ||
|
||
args, unknown_args = p.parse_known_args(args=command_line_args) | ||
if len(unknown_args): | ||
unknown_args_text = ", ".join(unknown_args) | ||
raise Exception(f"Unknown args: {unknown_args_text}") | ||
|
||
return args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,6 @@ | |
entry_points={ | ||
"console_scripts": [ | ||
"execute = electrical_heating_job.entry_point:execute", | ||
] | ||
] | ||
}, | ||
) |