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

DRAFT: Run CI stage in parallel for faster feedback #3169

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
268 changes: 266 additions & 2 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

go get "$repo/v2@$sha"

test-generator:
test-controller:
runs-on: [self-hosted, 1ES.Pool=aso-1es-pool]
permissions:
packages: read
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
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
docker exec "$container_id" task controller:ci

EXIT_CODE=$?
set -e
Expand Down Expand Up @@ -138,6 +138,270 @@ jobs:
run: bash <(curl -s https://codecov.io/bash)
if: steps.check-changes.outputs.code-changed == 'true'

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 generator: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: 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'

test-asoctl:
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 asoctl: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: 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'

test-crossplane:
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 crossplane: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: 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]
Expand Down
3 changes: 3 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,9 @@ tasks:
deps:
- basic-checks
- crossplane:generate-crds
cmds:
- task: verify-no-changes


############### Documentation targets ###############

Expand Down