Skip to content

Commit

Permalink
Fixing a format issue
Browse files Browse the repository at this point in the history
Signed-off-by: ytimocin <ytimocin@microsoft.com>
  • Loading branch information
ytimocin committed Jul 16, 2024
1 parent 56e8f05 commit 46549d9
Show file tree
Hide file tree
Showing 21 changed files with 402 additions and 689 deletions.
18 changes: 9 additions & 9 deletions .github/actions/process-test-results/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ description: |
test results format which is what we require.
GOTESTSUM_OPTS: '--junitfile ./dist/unit_test_results_raw.xml'
Then running 'make <test target>' will do the right thing :)
inputs:
test_group_name:
description: 'Name to use for reporting (eg: Unit Tests)'
description: "Name to use for reporting (eg: Unit Tests)"
required: true
artifact_name:
description: 'Name to use for uploading artifacts (eg: unit_test_results)'
description: "Name to use for uploading artifacts (eg: unit_test_results)"
required: true
result_directory:
description: 'Directory containing result XML files. These should be in jUnit format. See the description of the action.'
description: "Directory containing result XML files. These should be in jUnit format. See the description of the action."
required: true
runs:
using: "composite"
steps:
# The test results file output by gotestsum is missing file and line number on the XML elements
# which is needed for the annotations to work. This script adds the missing information.
- name: 'Transform ${{ inputs.test_group_name }} Results'
- name: "Transform ${{ inputs.test_group_name }} Results"
# Always is REQUIRED here. Otherwise, the action will be skipped when the unit tests fail, which
# defeats the purpose. YES it is counterintuitive. This applies to all of the actions in this file.
if: always()
id: 'process_files'
shell: 'bash'
id: "process_files"
shell: "bash"
working-directory: ${{ github.workspace }}
env:
INPUT_DIRECTORY: ${{ inputs.result_directory }}
Expand All @@ -52,14 +52,14 @@ runs:
python3 ./.github/scripts/transform_test_results.py $GITHUB_WORKSPACE "$INPUT_FILE" "$OUTPUT_FILE"
echo "wrote ${OUTPUT_FILE}"
done
- name: 'Create ${{ inputs.test_group_name }} Result Report'
- name: "Create ${{ inputs.test_group_name }} Result Report"
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
check_name: ${{ inputs.test_group_name }}
files: |
${{ inputs.result_directory }}/processed/*.xml
- name: 'Upload ${{ inputs.test_group_name }} Results'
- name: "Upload ${{ inputs.test_group_name }} Results"
uses: actions/upload-artifact@v4
if: always()
with:
Expand Down
20 changes: 13 additions & 7 deletions .github/scripts/publish-recipes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# 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
Expand Down Expand Up @@ -50,12 +50,11 @@ if [[ -z "$GITHUB_STEP_SUMMARY" ]]; then
GITHUB_STEP_SUMMARY=/dev/null
fi

echo "## Recipes published to $REGISTRY_PATH" >> $GITHUB_STEP_SUMMARY
for RECIPE in $(find "$DIRECTORY" -type f -name "*.bicep")
do
echo "## Recipes published to $REGISTRY_PATH" >>$GITHUB_STEP_SUMMARY
for RECIPE in $(find "$DIRECTORY" -type f -name "*.bicep"); do
FILENAME=$(basename $RECIPE)
PUBLISH_REF="$REGISTRY_PATH/${FILENAME%.*}:$RECIPE_VERSION"

# Skip files that start with _. These are not recipes, they are modules that are
# used by the recipes.
if [[ $(basename $RECIPE) =~ ^_.* ]]; then
Expand All @@ -64,6 +63,13 @@ do
fi

echo "Publishing $RECIPE to $PUBLISH_REF"
echo "- $PUBLISH_REF" >> $GITHUB_STEP_SUMMARY
rad bicep publish --file $RECIPE --target "br:$PUBLISH_REF"
echo "- $PUBLISH_REF" >>$GITHUB_STEP_SUMMARY

# Check if `LOCAL_REGISTRY` environment variable is set and is set to true
# If not, use HTTPS to publish the recipe
if [[ -n "$LOCAL_REGISTRY" && "$LOCAL_REGISTRY" == "true" ]]; then
rad bicep publish --file $RECIPE --target "br:$PUBLISH_REF" --plain-http
else
rad bicep publish --file $RECIPE --target "br:$PUBLISH_REF"
fi
done
18 changes: 11 additions & 7 deletions .github/scripts/publish-test-terraform-recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# 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
Expand Down Expand Up @@ -35,13 +35,14 @@
# Write output to stdout all of the time, and the step summary if we're in Github Actions.
step_summary = os.getenv("GITHUB_STEP_SUMMARY")
with open(step_summary, "a") if step_summary else contextlib.suppress() as output:

def log(message):
print(message, flush=True)
if step_summary:
output.write(message + "\n")

log("Publishing recipes from " + recipe_root + " to " + namespace + "/" + config_map_name)
log("Publishing recipes from " + recipe_root +
" to " + namespace + "/" + config_map_name)

# Get the list of subfolders in the recipe root. Each one is a recipe.
recipe_dirs = [f.path for f in os.scandir(recipe_root) if f.is_dir()]
Expand All @@ -60,22 +61,25 @@ def log(message):
log("Processing recipe: " + recipe_dir)

# Make the zip.
output_filename = shutil.make_archive(os.path.join(tmp_dir, os.path.basename(recipe_dir)), 'zip', recipe_dir)
output_filename = shutil.make_archive(os.path.join(
tmp_dir, os.path.basename(recipe_dir)), 'zip', recipe_dir)
log("Created zip file: " + output_filename)

# Add to config entries
config_entries[os.path.basename(recipe_dir)] = output_filename

# Delete the configmap if it already exists
args = ["kubectl", "delete", "configmap", config_map_name, "--namespace", namespace, "--ignore-not-found=true"]
args = ["kubectl", "delete", "configmap", config_map_name,
"--namespace", namespace, "--ignore-not-found=true"]
process = subprocess.run(args)
process.check_returncode()

# Create the configmap
args = ["kubectl", "create", "configmap", config_map_name, "--namespace", namespace]
args = ["kubectl", "create", "configmap",
config_map_name, "--namespace", namespace]
for recipe_name, zip_file in config_entries.items():
args.append("--from-file=" + recipe_name + ".zip=" + zip_file)

process = subprocess.run(args)
process.check_returncode()
log("Created configmap: " + namespace + "/" + config_map_name)
log("Created configmap: " + namespace + "/" + config_map_name)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# 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
Expand All @@ -14,12 +14,13 @@
# limitations under the License.
# ------------------------------------------------------------

name: Functional tests
name: Functional Tests (with Cloud Resources)

permissions:
id-token: write # Required for requesting the JWT
contents: read # Required for listing the commits
contents: read # Required for listing the commits
packages: write # Required for uploading the package
checks: write # Required for creating a check run

on:
# Enable manual trigger
Expand All @@ -33,31 +34,31 @@ on:
repository_dispatch:
types: [de-functional-test]
workflow_run:
workflows: ['Approve Functional Tests']
workflows: ["Approve Functional Tests"]
types:
- completed

env:
# Go version
GOVER: '1.22.2'
GOVER: "1.22.2"
GOPROXY: https://proxy.golang.org

# gotestsum version - see: https://github.com/gotestyourself/gotestsum
GOTESTSUM_VER: 1.10.0
GOTESTSUM_VER: 1.12.0

# Helm version
HELM_VER: 'v3.12.0'
HELM_VER: "v3.12.0"
# KinD cluster version
KIND_VER: 'v0.20.0'
KIND_VER: "v0.20.0"
# Dapr version
DAPR_VER: '1.12.0'
DAPR_DASHBOARD_VER: '0.14.0'
DAPR_VER: "1.12.0"
DAPR_DASHBOARD_VER: "0.14.0"
# Kubectl version
KUBECTL_VER: 'v1.25.0'
KUBECTL_VER: "v1.25.0"
# Azure Keyvault CSI driver chart version
AZURE_KEYVAULT_CSI_DRIVER_VER: '1.4.2'
AZURE_KEYVAULT_CSI_DRIVER_VER: "1.4.2"
# Azure workload identity webhook chart version
AZURE_WORKLOAD_IDENTITY_WEBHOOK_VER: '1.1.0'
AZURE_WORKLOAD_IDENTITY_WEBHOOK_VER: "1.1.0"
# Container registry for storing container images
CONTAINER_REGISTRY: ghcr.io/radius-project/dev
# Container registry for storing Bicep recipe artifacts
Expand All @@ -71,11 +72,11 @@ env:
# The Radius helm chart location.
RADIUS_CHART_LOCATION: deploy/Chart/
# The region for AWS resources
AWS_REGION: 'us-west-2'
AWS_REGION: "us-west-2"
# The AWS account ID
AWS_ACCOUNT_ID: '${{ secrets.FUNCTEST_AWS_ACCOUNT_ID }}'
AWS_ACCOUNT_ID: "${{ secrets.FUNCTEST_AWS_ACCOUNT_ID }}"
# The current GitHub action link
ACTION_LINK: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
ACTION_LINK: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# Server where terraform test modules are deployed
TF_RECIPE_MODULE_SERVER_URL: "http://tf-module-server.radius-test-tf-module-server.svc.cluster.local"
# The functional test GitHub app id
Expand All @@ -91,8 +92,8 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'repository_dispatch' || (github.event_name == 'schedule' && github.repository == 'radius-project/radius') || github.event_name == 'workflow_run'
env:
DE_IMAGE: 'ghcr.io/radius-project/deployment-engine'
DE_TAG: 'latest'
DE_IMAGE: "ghcr.io/radius-project/deployment-engine"
DE_TAG: "latest"
outputs:
REL_VERSION: ${{ steps.gen-id.outputs.REL_VERSION }}
UNIQUE_ID: ${{ steps.gen-id.outputs.UNIQUE_ID }}
Expand All @@ -106,7 +107,7 @@ jobs:
- name: Get GitHub app token
uses: tibdex/github-app-token@v2
id: get_installation_token
with:
with:
app_id: ${{ env.FUNCTIONAL_TEST_APP_ID }}
private_key: ${{ secrets.FUNCTIONAL_TEST_APP_PRIVATE_KEY }}
- name: Set up checkout target (scheduled)
Expand All @@ -117,16 +118,16 @@ jobs:
- name: Set up checkout target (pull_request)
if: github.event_name == 'pull_request'
run: |
echo "CHECKOUT_REPO=${{ github.repository }}" >> $GITHUB_ENV
echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
echo "CHECKOUT_REPO=${{ github.repository }}" >> $GITHUB_ENV
echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
- name: Use custom actions
uses: actions/checkout@v4
- name: 'Download PR data artifacts'
- name: "Download PR data artifacts"
if: github.event_name == 'workflow_run'
uses: ./.github/actions/download-pr-data-artifact
id: get-pr-number
- name: 'Set PR context (workflow_run)'
- name: "Set PR context (workflow_run)"
if: github.event_name == 'workflow_run'
uses: actions/github-script@v7
with:
Expand Down Expand Up @@ -175,7 +176,7 @@ jobs:
fi
UNIQUE_ID=func$(echo $BASE_STR | sha1sum | head -c 10)
echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_ENV
# Set output variables to be used in the other jobs
echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_OUTPUT
echo "UNIQUE_ID=${UNIQUE_ID}" >> $GITHUB_OUTPUT
Expand All @@ -194,7 +195,7 @@ jobs:
header: teststatus-${{ github.run_id }}
number: ${{ env.PR_NUMBER }}
hide: true
hide_classify: 'OUTDATED'
hide_classify: "OUTDATED"
message: |
## Radius functional test overview
Expand Down Expand Up @@ -223,7 +224,7 @@ jobs:
* deployment-engine test image location: `${{ env.DE_IMAGE }}:${{ env.DE_TAG }}`
</details>
## Test Status
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand Down Expand Up @@ -345,14 +346,14 @@ jobs:
- name: Get GitHub app token
uses: tibdex/github-app-token@v2
id: get_installation_token
with:
with:
app_id: ${{ env.FUNCTIONAL_TEST_APP_ID }}
private_key: ${{ secrets.FUNCTIONAL_TEST_APP_PRIVATE_KEY }}
- uses: LouisBrunner/checks-action@v2.0.0
if: always()
with:
token: ${{ steps.get_installation_token.outputs.token }}
name: 'Functional Test Run'
name: "Functional Test Run"
status: in_progress
repo: ${{ github.repository }}
sha: ${{ env.CHECKOUT_REF }}
Expand Down Expand Up @@ -577,15 +578,15 @@ jobs:
BICEP_RECIPE_REGISTRY: ${{ env.BICEP_RECIPE_REGISTRY }}
BICEP_RECIPE_TAG_VERSION: ${{ env.BICEP_RECIPE_TAG_VERSION }}
GH_TOKEN: ${{ steps.get_installation_token.outputs.token }}
GOTESTSUM_OPTS: '--junitfile ./dist/functional_test/results.xml'
GOTESTSUM_OPTS: "--junitfile ./dist/functional_test/results.xml"
- name: Process Functional Test Results
uses: ./.github/actions/process-test-results
# In case of failure, upload functional_test_results to artifacts so that they are not erased by subsequent runs.
if: failure() && github.repository == 'radius-project/radius'
with:
test_group_name: 'Functional Tests - ${{ matrix.name }}'
artifact_name: 'functional_test_results_${{ matrix.name }}'
result_directory: 'dist/functional_test/'
test_group_name: "Functional Tests - ${{ matrix.name }}"
artifact_name: "functional_test_results_${{ matrix.name }}"
result_directory: "dist/functional_test/"
- uses: azure/setup-kubectl@v4
if: always()
with:
Expand Down Expand Up @@ -620,7 +621,7 @@ jobs:
echo "Pod logs saved to recipes/pod-logs/"
# Get kubernetes events and save to file
kubectl get events -n $namespace > recipes/pod-logs/events.txt
- name: Upload Terraform recipe publishing logs
- name: Upload Terraform recipe publishing logs
uses: actions/upload-artifact@v4
if: always()
with:
Expand Down Expand Up @@ -676,7 +677,7 @@ jobs:
- name: Get GitHub app token
uses: tibdex/github-app-token@v2
id: get_installation_token
with:
with:
app_id: ${{ env.FUNCTIONAL_TEST_APP_ID }}
private_key: ${{ secrets.FUNCTIONAL_TEST_APP_PRIVATE_KEY }}
- name: Get tests job status
Expand All @@ -703,7 +704,7 @@ jobs:
if: always()
with:
token: ${{ steps.get_installation_token.outputs.token }}
name: 'Functional Test Run'
name: "Functional Test Run"
repo: ${{ github.repository }}
sha: ${{ env.CHECKOUT_REF }}
status: completed
Expand All @@ -725,11 +726,11 @@ jobs:
response = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'functional-test.yaml',
workflow_id: 'functional-test-cloud.yaml',
event: 'schedule',
per_page: 10
});
failureCount = 1;
for (const run of response.data.workflow_runs) {
if (run.conclusion === 'failure') {
Expand All @@ -751,4 +752,4 @@ jobs:
title: `Scheduled functional test failed - Run ID: ${context.runId}`,
labels: ['bug', 'test-failure'],
body: `## Bug information \n\nThis bug is generated automatically if the scheduled functional test fails at least ${process.env.ISSUE_CREATE_THRESHOLD} times in a row. The Radius functional test operates on a schedule of every 4 hours during weekdays and every 12 hours over the weekend. It's important to understand that the test may fail due to workflow infrastructure issues, like network problems, rather than the flakiness of the test itself. For the further investigation, please visit [here](${process.env.ACTION_LINK}).`
})
})
Loading

0 comments on commit 46549d9

Please sign in to comment.