From 7e06505595f859a9acd1e32a30c8af5812f2d2f8 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Fri, 2 Aug 2024 15:53:56 +0200 Subject: [PATCH 1/2] ci: add validator --- .github/workflows/validate.yml | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/validate.yml diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 00000000..93d5794f --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,63 @@ +name: Validator Bot + +on: + pull_request: + branches: + - master + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + run-validation: + name: Run validation + runs-on: self-hosted + steps: + - uses: lkstrp/pypsa-validator@main + with: + step: run-self-hosted-validation + env_file: environment.yaml + snakemake_config: config/config.yaml + pre_command: "-call build_scenarios -f" + + upload-artifacts: + name: Upload artifacts + needs: run-validation + runs-on: self-hosted + strategy: + matrix: + include: + - {artifact_name: "results (feature branch)", path: "~/pypsa-ariadne/feature/results"} + - {artifact_name: "results (base branch)", path: "~/pypsa-ariadne/main/results"} + - {artifact_name: "validator-metadata", path: "~/pypsa-ariadne/validator-metadata.yml"} + steps: + - name: Upload artifacts - ${{ matrix.artifact_name }} + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact_name }} + path: | + ${{ matrix.path }} + if-no-files-found: error + retention-days: 90 + + comment-on-pr: + name: Comment on pull request + needs: upload-artifacts + runs-on: ubuntu-latest + steps: + - uses: lkstrp/pypsa-validator@main + with: + step: create-comment + snakemake_config: config/config.yaml + # The path starting from prefix in config + # For plot results///.png pass + # /.png + plots: > + " + KN2045_Bal_v4/graphs/energy.svg + KN2045_Bal_v4/graphs/costs.svg + KN2045_Bal_v4/graphs/balances-AC.svg + " + repo_private_key: ${{ secrets.REPO_PLOTS_PRIVATE_KEY }} From 15efdb1a5f2f18c33fb04a84d270df978f8201f0 Mon Sep 17 00:00:00 2001 From: lkstrp Date: Mon, 5 Aug 2024 17:42:53 +0200 Subject: [PATCH 2/2] select images and add repo owner path --- .github/workflows/validate.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 93d5794f..efe0cd28 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -29,9 +29,9 @@ jobs: strategy: matrix: include: - - {artifact_name: "results (feature branch)", path: "~/pypsa-ariadne/feature/results"} - - {artifact_name: "results (base branch)", path: "~/pypsa-ariadne/main/results"} - - {artifact_name: "validator-metadata", path: "~/pypsa-ariadne/validator-metadata.yml"} + - {artifact_name: "results (feature branch)", path: "~/${{ github.repository }}/feature/results"} + - {artifact_name: "results (base branch)", path: "~/${{ github.repository }}/main/results"} + - {artifact_name: "validator-metadata", path: "~/${{ github.repository }}/validator-metadata.yml"} steps: - name: Upload artifacts - ${{ matrix.artifact_name }} uses: actions/upload-artifact@v4 @@ -56,8 +56,8 @@ jobs: # /.png plots: > " - KN2045_Bal_v4/graphs/energy.svg - KN2045_Bal_v4/graphs/costs.svg - KN2045_Bal_v4/graphs/balances-AC.svg + KN2045_Bal_v4/ariadne/primary_energy.png + KN2045_Bal_v4/ariadne/secondary_energy.png + KN2045_Bal_v4/ariadne/final_energy.png " repo_private_key: ${{ secrets.REPO_PLOTS_PRIVATE_KEY }}