Skip to content

Commit

Permalink
Update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronCrawfis committed Oct 10, 2023
1 parent 75ff491 commit 68bbfb9
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 125 deletions.
152 changes: 49 additions & 103 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,131 +28,79 @@ env:

jobs:
# TODO_LAUNCH: Remove this build job once we opensource the repo - https://github.com/radius-project/samples/issues/439
build:
build-acr:
name: Build and push sample images to ACR
if: github.event.action != 'closed'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- directory: samples/demo/
image: samples/demo
- directory: samples/dapr/ui/
image: samples/dapr-frontend
- direcotry: samples/dapr/nodeapp/
image: samples/dapr-backend
- directory: samples/aws/
image: samples/aws
- directory: samples/aws-sqs/
image: samples/aws-sqs
- directory: samples/volumes/
image: samples/volumes
steps:
- name: Checkout code
uses: actions/checkout@v3.5.2
uses: actions/checkout@v4
- name: Login to container registry
uses: azure/docker-login@v1
with:
login-server: ${{ env.DOCKER_REGISTRY }}
username: '${{ secrets.AZURE_SP_DOCKER_USERNAME }}'
password: '${{ secrets.AZURE_SP_DOCKER_PASSWORD }}'
- name: demo
uses: docker/build-push-action@v4
with:
context: ./demo/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.DOCKER_REGISTRY }}/tutorial/demo:${{ env.VERSION }}
- name: webapp
uses: docker/build-push-action@v4
with:
context: ./demo/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.DOCKER_REGISTRY }}/tutorial/webapp:${{ env.VERSION }}
- name: dapr-backend
uses: docker/build-push-action@v4
with:
context: ./quickstarts/dapr/nodeapp/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.DOCKER_REGISTRY }}/quickstarts/dapr-backend:${{ env.VERSION }}
- name: dapr-frontend
uses: docker/build-push-action@v4
with:
context: ./quickstarts/dapr/ui/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.DOCKER_REGISTRY }}/quickstarts/dapr-frontend:${{ env.VERSION }}
- name: aws-reference-app
uses: docker/build-push-action@v4
with:
context: ./reference-apps/aws/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.DOCKER_REGISTRY }}/reference-apps/aws:${{ env.VERSION }}
- name: environment-variables
uses: docker/build-push-action@v4
with:
context: ./quickstarts/environment-variables/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.DOCKER_REGISTRY }}/quickstarts/envvars:${{ env.VERSION }}
- name: volumes
uses: docker/build-push-action@v4
with:
context: ./quickstarts/volumes/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.DOCKER_REGISTRY }}/quickstarts/volumes:${{ env.VERSION }}
- name: aws-sqs
- name: Build and push ${{ matrix.image }}
uses: docker/build-push-action@v4
with:
context: ./reference-apps/aws-sqs/
context: ./${{ matrix.directory }}
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.DOCKER_REGISTRY }}/reference-apps/aws-sqs-sample:${{ env.VERSION }}
build-container:
tags: ${{ env.DOCKER_REGISTRY }}/${{ matrix.image }}:${{ env.VERSION }}
build-ghcr:
name: Build and push sample images to GHCR
if: github.event.action != 'closed'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- directory: samples/demo/
image: samples/demo
- directory: samples/dapr/ui/
image: samples/dapr-frontend
- direcotry: samples/dapr/nodeapp/
image: samples/dapr-backend
- directory: samples/aws/
image: samples/aws
- directory: samples/aws-sqs/
image: samples/aws-sqs
- directory: samples/volumes/
image: samples/volumes
steps:
- name: Checkout code
uses: actions/checkout@v3.5.2
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: demo
uses: docker/build-push-action@v4
with:
context: ./demo/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.CONTAINER_REGISTRY }}/tutorial/demo:${{ env.VERSION }}
- name: webapp
uses: docker/build-push-action@v4
with:
context: ./demo/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.CONTAINER_REGISTRY }}/tutorial/webapp:${{ env.VERSION }}
- name: dapr-backend
uses: docker/build-push-action@v4
with:
context: ./quickstarts/dapr/nodeapp/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.CONTAINER_REGISTRY }}/quickstarts/dapr-backend:${{ env.VERSION }}
- name: dapr-frontend
uses: docker/build-push-action@v4
with:
context: ./quickstarts/dapr/ui/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.CONTAINER_REGISTRY }}/quickstarts/dapr-frontend:${{ env.VERSION }}
- name: aws-reference-app
uses: docker/build-push-action@v4
with:
context: ./reference-apps/aws/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.CONTAINER_REGISTRY }}/reference-apps/aws:${{ env.VERSION }}
- name: environment-variables
uses: docker/build-push-action@v4
with:
context: ./quickstarts/environment-variables/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.CONTAINER_REGISTRY }}/quickstarts/envvars:${{ env.VERSION }}
- name: volumes
uses: docker/build-push-action@v4
with:
context: ./quickstarts/volumes/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.CONTAINER_REGISTRY }}/quickstarts/volumes:${{ env.VERSION }}
- name: aws-sqs
- name: Build and push ${{ matrix.image }}
uses: docker/build-push-action@v4
with:
context: ./reference-apps/aws-sqs/
context: ./${{ matrix.directory }}
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.CONTAINER_REGISTRY }}/reference-apps/aws-sqs-sample:${{ env.VERSION }}
tags: ${{ env.CONTAINER_REGISTRY }}/${{ matrix.image }}:${{ env.VERSION }}

# TODO_LAUNCH: Remove this job once we opensource the repo because all pkgs will be cleaned up regularly - https://github.com/radius-project/samples/issues/439
cleanup:
Expand All @@ -163,19 +111,17 @@ jobs:
fail-fast: false
matrix:
image: [
tutorial/webapp,
tutorial/demo,
quickstarts/dapr-backend,
quickstarts/dapr-frontend,
quickstarts/envvars,
quickstarts/volumes,
reference-apps/aws,
reference-apps/aws-sqs-sample,
samples/demo,
samples/dapr-frontend,
samples/dapr-backend,
samples/aws,
samples/aws-sqs,
samples/volumes
]
steps:
- name: Login to az cli and ACR
run: |
az login --service-principal --username ${{ secrets.AZURE_SP_DOCKER_USERNAME }} --password ${{ secrets.AZURE_SP_DOCKER_PASSWORD }} --tenant ${{ secrets.AZURE_SP_DOCKER_TENANT }}
az acr login --name ${{ env.DOCKER_REGISTRY }}
- name: Delete PR images
run: az acr repository delete --name ${{ env.DOCKER_REGISTRY }} --image "${{ matrix.image }}:${{ env.VERSION }}" --yes
run: az acr repository delete --name ${{ env.DOCKER_REGISTRY }} --image "${{ matrix.image }}:${{ env.VERSION }}" --yes
37 changes: 15 additions & 22 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ on:
- v*.*
- edge
paths:
- "quickstarts/**"
- "reference-apps/**"
- "demo/**"
- "samples/**"
- ".github/workflows/**"
pull_request:
types: [opened, synchronize, reopened]
Expand All @@ -38,45 +36,40 @@ jobs:
- name: demo
runOnPullRequest: true
app: demo
path: ./demo/app.bicep
path: ./samples/demo/app.bicep
args: --application demo
uiTestFile: tests/demo/demo.app.spec.ts
port: 3000
container: demo
enableDapr: false
- name: dapr
runOnPullRequest: true
app: dapr-quickstart
path: ./quickstarts/dapr/dapr.bicep
app: dapr
path: ./samples/dapr/dapr.bicep
enableDapr: true
- name: environment-variables
runOnPullRequest: true
app: myapp
path: ./quickstarts/environment-variables/app.bicep
enableDapr: false
- name: volumes
runOnPullRequest: true
app: myapp
path: ./quickstarts/volumes/app.bicep
path: ./samples/volumes/app.bicep
enableDapr: false
- name: eshop
runOnPullRequest: true
app: eshop
path: ./reference-apps/eshop/iac/eshop.bicep
path: ./samples/eshop/iac/eshop.bicep
uiTestFile: tests/eshop/container.app.spec.ts
enableDapr: false
- name: eshop-azure
runOnPullRequest: false
app: eshop-azure
path: ./reference-apps/eshop/iac/eshop.bicep
path: ./samples/eshop/iac/eshop.bicep
args: -p platform=azure -p appName=eshop-azure
uiTestFile: tests/eshop/container.app.spec.ts
credential: azure
enableDapr: false
- name: eshop-aws
runOnPullRequest: false
app: eshop-aws-${{ github.run_id }}-${{ github.run_attempt }}
path: ./reference-apps/eshop/iac/eshop.bicep
path: ./samples/eshop/iac/eshop.bicep
args: -p platform=aws -p eksClusterName=eks-samplestest-${{ github.run_id }}-${{ github.run_attempt }}-eshop-aws -p appName=eshop-aws-${{ github.run_id }}-${{ github.run_attempt }}
uiTestFile: tests/eshop/container.app.spec.ts
credential: aws
Expand Down Expand Up @@ -250,7 +243,7 @@ jobs:
echo "Endpoint: $endpoint"
export ENDPOINT=$endpoint
fi
cd ui-tests/
cd playwright/
npm ci
npx playwright install --with-deps
npx playwright test ${{ matrix.uiTestFile }} --retries 3
Expand All @@ -259,7 +252,7 @@ jobs:
if: always() && ( steps.run-playwright-test.outcome == 'success' || steps.run-playwright-test.outcome == 'failure' )
with:
name: playwright-report-${{ matrix.name }}
path: ui-tests/playwright-report/
path: playwright/playwright-report/
retention-days: 30
if-no-files-found: error
# Handle failures
Expand All @@ -268,23 +261,23 @@ jobs:
if: failure() && steps.run-playwright-test.outcome == 'failure'
run: |
# Create pod-logs directory
mkdir -p ui-tests/pod-logs/${{ matrix.name }}
mkdir -p playwright/pod-logs/${{ matrix.name }}
# Get pod logs and save to file
namespace="default-${{ matrix.app }}"
label="radius.dev/application=${{ matrix.app }}"
pod_names=($(kubectl get pods -l $label -n $namespace -o jsonpath='{.items[*].metadata.name}'))
for pod_name in "${pod_names[@]}"; do
kubectl logs $pod_name -n $namespace > ui-tests/pod-logs/${{ matrix.name }}/${pod_name}.txt
kubectl logs $pod_name -n $namespace > playwright/pod-logs/${{ matrix.name }}/${pod_name}.txt
done
echo "Pod logs saved to ui-tests/pod-logs/${{ matrix.name }}/"
echo "Pod logs saved to playwright/pod-logs/${{ matrix.name }}/"
# Get kubernetes events and save to file
kubectl get events -n $namespace > ui-tests/pod-logs/${{ matrix.name }}/events.txt
kubectl get events -n $namespace > playwright/pod-logs/${{ matrix.name }}/events.txt
- name: Upload Pod logs for failed tests
uses: actions/upload-artifact@v3
if: failure() && steps.get-pod-logs.outcome == 'success'
with:
name: ${{ matrix.name }}-pod-logs
path: ui-tests/pod-logs/${{ matrix.name }}
path: playwright/pod-logs/${{ matrix.name }}
retention-days: 30
if-no-files-found: error
- name: Create GitHub issue on failure
Expand Down

0 comments on commit 68bbfb9

Please sign in to comment.