Doc/add redis sample #6884
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validate Pull Request | |
on: | |
# runs on pushes to main in order to update the baseline code coverage | |
# so that PRs have something to compare against | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
merge_group: | |
branches: | |
- main | |
jobs: | |
test-go-get: | |
runs-on: ubuntu-latest | |
steps: | |
- name: '`go get` code' | |
run: | | |
# placeholder module so we can invoke go get | |
go mod init example.com/m | |
# note: cannot use github.sha here since that commit doesn't really exist | |
# however, since we require branches to always be up-to-date (GitHub setting), | |
# using the head of the PR branch should provide equivalent behaviour | |
sha='${{ github.event.pull_request.head.sha }}' | |
repo='${{ github.event.pull_request.head.repo.html_url}}' | |
repo=${repo#"https://"} # trim prefix | |
if [ "$repo" != "github.com/Azure/azure-service-operator" ]; then | |
echo "Skipping 'go get' check for fork…" | |
exit 0 | |
fi | |
if [ -z "$sha" ]; then | |
# this means we were triggered by push to 'main', | |
# not a PR, so use the sha that triggered this | |
sha='${{ github.sha }}' | |
fi | |
go get "$repo/v2@$sha" | |
test-generator: | |
runs-on: [self-hosted, 1ES.Pool=aso-1es-pool] | |
permissions: | |
packages: read | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # required to access tags | |
submodules: 'true' | |
- name: check-changes | |
id: check-changes | |
run: scripts/v2/check-changes.sh | |
- name: Log in to GitHub Docker Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: docker.pkg.github.com # ghcr.io not yet enabled for Azure org | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
if: steps.check-changes.outputs.code-changed == 'true' | |
# Note: Changes to this step must also be mirrored into pr-validation-with-secrets.yaml | |
- name: Build devcontainer image | |
# We must issue a manual pull before the build so the image gets copied locally, because | |
# docker.pkg.github.com is not a valid Docker registry and doesn't work with --cache-from, | |
# however, `docker pull` will fall back to other methods that do work and get the image loaded. | |
# | |
# This message comes from "docker pull": | |
# | |
# Run docker pull docker.pkg.github.com/azure/azure-service-operator/aso-devcontainer:latest | |
# WARNING: ⚠️ Failed to pull manifest by the resolved digest. This registry does not | |
# appear to conform to the distribution registry specification; falling back to | |
# pull by tag. This fallback is DEPRECATED, and will be removed in a future | |
# release. Please contact admins of https://docker.pkg.github.com. ⚠️ | |
# | |
# See: https://github.com/moby/moby/issues/41687#issuecomment-733826074 and related issues | |
run: | | |
docker pull docker.pkg.github.com/azure/azure-service-operator/aso-devcontainer:latest | |
docker build --cache-from docker.pkg.github.com/azure/azure-service-operator/aso-devcontainer:latest --tag devcontainer:latest .devcontainer | |
env: | |
DOCKER_BUILDKIT: 1 | |
if: steps.check-changes.outputs.code-changed == 'true' | |
- name: Run devcontainer image | |
id: devcontainer | |
run: | | |
container_id=$(docker create -w /workspace -v $GITHUB_WORKSPACE:/workspace -v /var/run/docker.sock:/var/run/docker.sock --network=host devcontainer:latest) | |
docker start "$container_id" | |
echo "container_id=$container_id" >> $GITHUB_ENV | |
if: steps.check-changes.outputs.code-changed == 'true' | |
- name: Run CI tasks | |
run: | | |
container_id=${{ env.container_id }} | |
set +e # don't exit instantly on failure, we need to produce Markdown summary | |
docker exec "$container_id" task ci | |
EXIT_CODE=$? | |
set -e | |
# generate summary Markdown file for display in Actions | |
cat reports/*.md > $GITHUB_STEP_SUMMARY | |
exit $EXIT_CODE | |
if: steps.check-changes.outputs.code-changed == 'true' | |
- name: Save JSON logs on failure | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v3.1.2 | |
with: | |
name: test-output | |
path: reports/*.json | |
- name: Build docker image & build configuration YAML | |
run: | | |
container_id=${{ env.container_id }} | |
docker exec "$container_id" task controller:docker-build-and-save | |
docker exec "$container_id" task controller:run-kustomize-for-envtest | |
if: steps.check-changes.outputs.code-changed == 'true' | |
- name: Archive outputs | |
uses: actions/upload-artifact@v3.1.2 | |
with: | |
name: output | |
path: v2/bin/* | |
if-no-files-found: error | |
if: steps.check-changes.outputs.code-changed == 'true' | |
- name: Upload code coverage to Codecov | |
run: bash <(curl -s https://codecov.io/bash) | |
if: steps.check-changes.outputs.code-changed == 'true' | |
# TODO: Changing this name requires changing the github API calls in pr-validation-fork.yml | |
integration-tests: | |
runs-on: [self-hosted, 1ES.Pool=aso-1es-pool] | |
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
permissions: | |
packages: read | |
checks: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # required to access tags | |
submodules: 'true' | |
- name: check-changes | |
id: check-changes | |
run: scripts/v2/check-changes.sh | |
- name: Log in to GitHub Docker Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: docker.pkg.github.com # ghcr.io not yet enabled for Azure org | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
if: steps.check-changes.outputs.code-changed == 'true' | |
# Note: Changes to this step must also be mirror into pr-validation.yaml | |
- name: Build devcontainer image | |
# We must issue a manual pull before the build so the image gets copied locally, because | |
# docker.pkg.github.com is not a valid Docker registry and doesn't work with --cache-from, | |
# however, `docker pull` will fall back to other methods that do work and get the image loaded. | |
# | |
# This message comes from "docker pull": | |
# | |
# Run docker pull docker.pkg.github.com/azure/azure-service-operator/aso-devcontainer:latest | |
# WARNING: ⚠️ Failed to pull manifest by the resolved digest. This registry does not | |
# appear to conform to the distribution registry specification; falling back to | |
# pull by tag. This fallback is DEPRECATED, and will be removed in a future | |
# release. Please contact admins of https://docker.pkg.github.com. ⚠️ | |
# | |
# See: https://github.com/moby/moby/issues/41687#issuecomment-733826074 and related issues | |
run: | | |
docker pull docker.pkg.github.com/azure/azure-service-operator/aso-devcontainer:latest | |
docker build --cache-from docker.pkg.github.com/azure/azure-service-operator/aso-devcontainer:latest --tag devcontainer:latest .devcontainer | |
env: | |
DOCKER_BUILDKIT: 1 | |
if: steps.check-changes.outputs.code-changed == 'true' | |
- name: Run devcontainer image | |
id: devcontainer | |
run: | | |
container_id=$(docker create -w /workspace -v $GITHUB_WORKSPACE:/workspace -v /var/run/docker.sock:/var/run/docker.sock --network=host devcontainer:latest) | |
docker start "$container_id" | |
echo "container_id=$container_id" >> $GITHUB_ENV | |
if: steps.check-changes.outputs.code-changed == 'true' | |
- name: Run integration tests | |
run: | | |
container_id=${{ env.container_id }} | |
docker exec --env HOSTROOT=$GITHUB_WORKSPACE -e AZURE_TENANT_ID -e AZURE_CLIENT_ID -e AZURE_CLIENT_SECRET -e AZURE_SUBSCRIPTION_ID -e AZURE_CLIENT_SECRET_MULTITENANT -e AZURE_CLIENT_ID_MULTITENANT -e AZURE_CLIENT_ID_CERT_AUTH -e AZURE_CLIENT_SECRET_CERT_AUTH "$container_id" task controller:ci-integration-tests | |
env: | |
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | |
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | |
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} | |
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
AZURE_CLIENT_SECRET_MULTITENANT: ${{ secrets.AZURE_CLIENT_SECRET_MULTITENANT }} | |
AZURE_CLIENT_ID_MULTITENANT: ${{ secrets.AZURE_CLIENT_ID_MULTITENANT }} | |
AZURE_CLIENT_ID_CERT_AUTH: ${{ secrets.AZURE_CLIENT_ID_CERT_AUTH }} | |
AZURE_CLIENT_SECRET_CERT_AUTH: ${{ secrets.AZURE_CLIENT_SECRET_CERT_AUTH }} | |
if: steps.check-changes.outputs.code-changed == 'true' | |
# Update check run called "integration-tests-fork" | |
- name: update-integration-tests-result | |
uses: actions/github-script@v6 | |
id: update-check-run | |
if: ${{ always() }} | |
env: | |
number: ${{ github.event.number }} | |
integration_test_job: 'integration-tests-fork' # This is the name of the job defined in pr-validation-fork.yml | |
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run | |
conclusion: ${{ job.status }} | |
server_url: ${{ github.server_url }} | |
repo: ${{ github.repository }} | |
run_id: ${{ github.run_id }} | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const url = `${process.env.server_url}/${process.env.repo}/actions/runs/${process.env.run_id}` | |
const { data: pull } = await github.rest.pulls.get({ | |
...context.repo, | |
pull_number: process.env.number | |
}); | |
const ref = pull.head.sha; | |
const { data: result } = await github.rest.checks.create({ | |
...context.repo, | |
name: process.env.integration_test_job, | |
head_sha: ref, | |
status: 'completed', | |
conclusion: process.env.conclusion, | |
details_url: url, | |
}); | |
return result; |