diff --git a/.github/scripts/tests/transform-ya-junit.py b/.github/scripts/tests/transform-ya-junit.py index 39eac048c09..611191367fb 100755 --- a/.github/scripts/tests/transform-ya-junit.py +++ b/.github/scripts/tests/transform-ya-junit.py @@ -173,6 +173,7 @@ def transform( log_url_prefix, log_out_dir, log_trunc_size, + output, ): tree = ET.parse(fp) root = tree.getroot() @@ -225,8 +226,11 @@ def transform( if save_inplace: tree.write(fp.name) else: - ET.indent(root) - print(ET.tostring(root, encoding="unicode")) + if output: + tree.write(output) + else: + ET.indent(root) + print(ET.tostring(root, encoding="unicode")) def main(): @@ -238,6 +242,15 @@ def main(): default=False, help="modify input file in-place", ) + parser.add_argument( + "-o", + "--output", + dest="output", + default=False, + help="""set output path. If -i specified this parameter will be ignored. + If -i not specified and this parameter also not specified + everything will be dumped to stdout""", + ) parser.add_argument("-m", help="muted test list") parser.add_argument("--log-url-prefix", default="./", help="url prefix for logs") parser.add_argument("--log-out-dir", help="symlink logs to specific directory") @@ -268,6 +281,7 @@ def main(): args.log_url_prefix, args.log_out_dir, args.log_trunc_size, + args.output, ) diff --git a/.github/workflows/github_actions_scripts.yaml b/.github/workflows/github_actions_scripts.yaml new file mode 100644 index 00000000000..169ab1c81cf --- /dev/null +++ b/.github/workflows/github_actions_scripts.yaml @@ -0,0 +1,92 @@ +name: NBS Github Actions script testing +on: + workflow_dispatch: + workflow_call: + +jobs: + index: + name: Test GA scripts + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Prepare VM + uses: ./.github/actions/prepare + - name: Prepare env + shell: bash + run: | + echo "SHELLOPTS=$SHELLOPTS:xtrace" >> $GITHUB_ENV + echo "TMP_DIR=$(mktemp -d)" >> $GITHUB_ENV + - name: Prepare test data + shell: bash + run: | + set -x + mkdir -p $GITHUB_WORKSPACE/.github/scripts/tests/test-data/ + cd $GITHUB_WORKSPACE/.github/scripts/tests/test-data/ + wget https://storage.ai.nebius.cloud/github-actions-test-data/cloud.tar.gz + tar zxvf cloud.tar.gz + - name: Launch transform-ya-junit.py + shell: bash + run: | + set -x + echo "::group::transform-junit" + python3 .github/scripts/tests/transform-ya-junit.py \ + --output "$TMP_DIR/junit.xml" \ + -m .github/config/muted_ya.txt \ + --ya-out "$GITHUB_WORKSPACE/.github/scripts/tests/test-data/" \ + --log-url-prefix "LOG_URL_PREFIX" \ + --log-out-dir "$TMP_DIR" \ + ".github/scripts/tests/test-data/junit.xml" + echo "::endgroup::" + + - name: Launch generate-summary.py + shell: bash + run: | + set -x + echo "::group::generate-summary" + python3 .github/scripts/tests/generate-summary.py \ + --summary-out-path "$TMP_DIR" \ + --summary-out-env-path "$TMP_DIR/summary_env" \ + --summary-url-prefix "SUMMARY_URL_PREFIX" \ + --build-preset "linux-x64-relwithdebinfo" \ + "Tests" ya-test.html "$TMP_DIR/junit.xml" + echo "::endgroup::" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: "ydb-platform/nbs" + + - name: Launch fail-checker.py + shell: bash + run: | + set -x + echo "::group::fail-checker" + python3 .github/scripts/tests/fail-checker.py "$TMP_DIR/junit.xml" --paths-only | sort | tee -a "$TMP_DIR/fail-checker" + echo "::endgroup::" + - name: check md5 + shell: bash + run: | + echo "::group::check-md5" + # find . -type f -exec md5sum {} + > ../test-data/MD5SUMS + cp .github/scripts/tests/test-data/MD5SUMS $TMP_DIR/MD5SUMS + cd $TMP_DIR + md5sum -c MD5SUMS | tee -a RESULT + echo "::endgroup::" + - name: additional info in case of failure + if: failure() + shell: bash + run: | + cd $TMP_DIR + grep FAILED RESULT | awk -F: '{print $1}' | while read f; + do + echo "==========" + echo $f + cat $f + grep $f MD5SUMS + md5sum $f + if [ -f "${GITHUB_WORKSPACE}/.github/scripts/tests/test-data/${f}" ]; + then + diff -u ${GITHUB_WORKSPACE}/.github/scripts/tests/test-data/${f} ${f} + fi + echo "==========" + done + diff --git a/.github/workflows/pr-github-actions.yaml b/.github/workflows/pr-github-actions.yaml index 259656b4637..fe53b7ee1c1 100644 --- a/.github/workflows/pr-github-actions.yaml +++ b/.github/workflows/pr-github-actions.yaml @@ -17,6 +17,10 @@ defaults: run: shell: bash +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + jobs: shell: runs-on: ubuntu-latest @@ -123,4 +127,8 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, body: '${{ steps.lint.outputs.WORKFLOW_LINT }}' - }) \ No newline at end of file + }) + nbs-github-actions: + name: Launch scripts on test-data + uses: ./.github/workflows/github_actions_scripts.yaml + secrets: inherit \ No newline at end of file