Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests to run on .github folder update, to verify that all essential scripts are working correctly #285

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/scripts/tests/transform-ya-junit.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def transform(
log_url_prefix,
log_out_dir,
log_trunc_size,
output,
):
tree = ET.parse(fp)
root = tree.getroot()
Expand Down Expand Up @@ -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():
Expand All @@ -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")
Expand Down Expand Up @@ -268,6 +281,7 @@ def main():
args.log_url_prefix,
args.log_out_dir,
args.log_trunc_size,
args.output,
)


Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/github_actions_scripts.yaml
Original file line number Diff line number Diff line change
@@ -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

10 changes: 9 additions & 1 deletion .github/workflows/pr-github-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -123,4 +127,8 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
body: '${{ steps.lint.outputs.WORKFLOW_LINT }}'
})
})
nbs-github-actions:
name: Launch scripts on test-data
uses: ./.github/workflows/github_actions_scripts.yaml
secrets: inherit
Loading