diff --git a/.github/workflows/CoverageCollection.yml b/.github/workflows/CoverageCollection.yml index ec890b6..922a6a5 100644 --- a/.github/workflows/CoverageCollection.yml +++ b/.github/workflows/CoverageCollection.yml @@ -83,9 +83,10 @@ jobs: id: getVariables shell: python run: | - from os import getenv - from pathlib import Path - from tomli import load as tomli_load + from os import getenv + from pathlib import Path + from tomli import load as tomli_load + from textwrap import dedent htmlDirectory = 'htmlcov' xmlFile = './coverage.xml' @@ -93,34 +94,36 @@ jobs: # Read output paths from 'pyproject.toml' file if coverageRC == "pyproject.toml": - pyProjectFile = Path("pyproject.toml") - if pyProjectFile.exists(): - with pyProjectFile.open("rb") as file: - pyProjectSettings = tomli_load(file) + pyProjectFile = Path("pyproject.toml") + if pyProjectFile.exists(): + with pyProjectFile.open("rb") as file: + pyProjectSettings = tomli_load(file) - htmlDirectory = pyProjectSettings["tool"]["coverage"]["html"]["directory"] - xmlFile = pyProjectSettings["tool"]["coverage"]["xml"]["output"] - else: - print(f"File '{pyProjectFile}' not found and no ' .coveragerc' file specified.") + htmlDirectory = pyProjectSettings["tool"]["coverage"]["html"]["directory"] + xmlFile = pyProjectSettings["tool"]["coverage"]["xml"]["output"] + else: + print(f"File '{pyProjectFile}' not found and no ' .coveragerc' file specified.") # Read output paths from '.coveragerc' file elif len(coverageRC) > 0: - coverageRCFile = Path(coverageRC) - if coverageRCFile.exists(): - with coverageRCFile.open("rb") as file: - coverageRCSettings = tomli_load(file) + coverageRCFile = Path(coverageRC) + if coverageRCFile.exists(): + with coverageRCFile.open("rb") as file: + coverageRCSettings = tomli_load(file) - htmlDirectory = coverageRCSettings["html"]["directory"] - xmlFile = coverageRCSettings["xml"]["output"] - else: - print(f"File '{coverageRCFile}' not found.") + htmlDirectory = coverageRCSettings["html"]["directory"] + xmlFile = coverageRCSettings["xml"]["output"] + else: + print(f"File '{coverageRCFile}' not found.") # Write jobs to special file github_output = Path(getenv("GITHUB_OUTPUT")) print(f"GITHUB_OUTPUT: {github_output}") - with github_output.open("a+") as f: - f.write(f"coverage_report_html_directory={htmlDirectory}\n") - f.write(f"coverage_report_xml={xmlFile}\n") + with github_output.open("a+", encoding="utf-8") as f: + f.write(dedent(f"""\ + coverage_report_html_directory={htmlDirectory} + coverage_report_xml={xmlFile} + """)) print(f"DEBUG:\n html={htmlDirectory}\n xml={xmlFile}") @@ -155,7 +158,7 @@ jobs: continue-on-error: true uses: codecov/codecov-action@v3 with: - file: ${{ steps.getVariables.outputs.coverage_report_xml }} + files: ${{ steps.getVariables.outputs.coverage_report_xml }} flags: unittests env_vars: PYTHON diff --git a/.github/workflows/Parameters.yml b/.github/workflows/Parameters.yml index e90ae94..5bcb4a2 100644 --- a/.github/workflows/Parameters.yml +++ b/.github/workflows/Parameters.yml @@ -246,11 +246,13 @@ jobs: # Write jobs to special file github_output = Path(getenv("GITHUB_OUTPUT")) print(f"GITHUB_OUTPUT: {github_output}") - with github_output.open("a+") as f: - f.write(f"python_version={python_version}\n") - f.write(f"python_jobs={json_dumps(jobs)}\n") - f.write(f"artifact_names={json_dumps(artifact_names)}\n") - f.write(f"params={json_dumps(params)}\n") + with github_output.open("a+", encoding="utf-8") as f: + f.write(dedent(f"""\ + python_version={python_version} + python_jobs={json_dumps(jobs)} + artifact_names={json_dumps(artifact_names)} + params={json_dumps(params)} + """)) - name: Verify out parameters id: verify diff --git a/.github/workflows/StaticTypeCheck.yml b/.github/workflows/StaticTypeCheck.yml index 4a8e736..63e3304 100644 --- a/.github/workflows/StaticTypeCheck.yml +++ b/.github/workflows/StaticTypeCheck.yml @@ -94,7 +94,7 @@ jobs: - name: 📤 Upload 'Static Typing Report' JUnit artifact if: ${{ inputs.junit_artifact != '' }} continue-on-error: true - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: ${{ inputs.junit_artifact }} path: ${{ inputs.junit_report }} diff --git a/with-post-step/action.yml b/with-post-step/action.yml index 12aec6c..8e78a8c 100644 --- a/with-post-step/action.yml +++ b/with-post-step/action.yml @@ -37,6 +37,6 @@ inputs: default: POST runs: - using: 'node12' + using: 'node16' main: 'main.js' post: 'main.js' diff --git a/with-post-step/main.js b/with-post-step/main.js index 0fa6d9e..1a9c3f0 100644 --- a/with-post-step/main.js +++ b/with-post-step/main.js @@ -3,7 +3,8 @@ * Unai Martinez-Corral * * * * ================================================================================================================== * - * Copyright 2021 Unai Martinez-Corral * + * Copyright 2021-2022 Unai Martinez-Corral * + * Copyright 2022 Unai Martinez-Corral * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * @@ -25,12 +26,10 @@ * * https://github.com/actions/runner/issues/1478 * * ================================================================================================================== */ const { spawn } = require("child_process"); +const fs = require('fs'); -function run(cmdline) { - var args = cmdline.split(" "); - const cmd = args.shift(); - - const subprocess = spawn(cmd, args, { stdio: "inherit" }); +function run(cmd) { + const subprocess = spawn(cmd, { stdio: "inherit", shell: true }); subprocess.on("exit", (exitCode) => { process.exitCode = exitCode; }); @@ -41,6 +40,6 @@ const key = process.env.INPUT_KEY.toUpperCase(); if ( process.env[`STATE_${key}`] !== undefined ) { // Are we in the 'post' step? run(process.env.INPUT_POST); } else { // Otherwise, this is the main step - console.log(`::save-state name=${key}::true`); + fs.appendFileSync(process.env.GITHUB_STATE, `${key}=true`); run(process.env.INPUT_MAIN); }