Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/edge' into willdavsmith/ui-test-…
Browse files Browse the repository at this point in the history
…eshop-aws
  • Loading branch information
willdavsmith committed Sep 11, 2023
2 parents 7e0d0ae + 3629c82 commit 4b9991c
Show file tree
Hide file tree
Showing 46 changed files with 642 additions and 359 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# text files use OS defaults on checkout, LF on checkin
* text eol=auto
# images are binary
*.png binary
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners

# Default rule: anything that doesn't match a more specific rule goes here
* @project-radius/radius-pm
* @radius-project/radius-pm
42 changes: 42 additions & 0 deletions .github/scripts/release-samples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# ------------------------------------------------------------
# Copyright 2023 The Radius Authors.
#
# 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
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------

set -xe

VERSION_NUMBER=$1 # (e.g. 0.1.0)
REPOSITORY="samples"

if [[ -z "$VERSION_NUMBER" ]]; then
echo "Error: VERSION_NUMBER is not set."
exit 1
fi

# CHANNEL is the major and minor version of the VERSION_NUMBER (e.g. 0.1)
CHANNEL="$(echo $VERSION_NUMBER | cut -d '.' -f 1,2)"

# CHANNEL_VERSION is the version with the 'v' prefix (e.g. v0.1)
CHANNEL_VERSION="v${CHANNEL}"

echo "Version number: ${VERSION_NUMBER}"
echo "Channel: ${CHANNEL}"
echo "Channel version: ${CHANNEL_VERSION}"

echo "Creating release branch for ${REPOSITORY}..."

pushd $REPOSITORY
git checkout -B "${CHANNEL_VERSION}"
git push origin "${CHANNEL_VERSION}"
popd
9 changes: 5 additions & 4 deletions .github/scripts/validate_semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ def main():
SEMVER_REGEX = r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"

pattern = re.compile(SEMVER_REGEX)

version = sys.argv[1]
match = pattern.search(version)

# If no match, then return an error (provided version is not valid semver)
if match is None:

if version == "edge":
print("Provided version is edge")
sys.exit(0)
elif match is None:
print("Provided version is not valid semver")
sys.exit(1)
else:
Expand Down
154 changes: 121 additions & 33 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,19 @@ concurrency:
env:
VERSION: ${{ github.event.pull_request.number || 'edge' }}
# Use radiusdev.azurecr.io for PR build. Otherwise, use radius.azurecr.io.
# TODO_LAUNCH: Remove this env var once we opensource the repo - https://github.com/radius-project/samples/issues/439
DOCKER_REGISTRY: ${{ github.event.pull_request.number && 'radiusdev.azurecr.io' || 'radius.azurecr.io' }}
# Use radiusdev.azurecr.io for PR build. Otherwise, use radius.azurecr.io.
CONTAINER_REGISTRY: ${{ github.event.pull_request.number && 'ghcr.io/radius-project/dev' || 'ghcr.io/radius-project/samples' }}
# Set to true to push images to registry.
PUSH_IMAGE: true

jobs:
# TODO_LAUNCH: Remove this build job once we opensource the repo - https://github.com/radius-project/samples/issues/439
build:
name: Build and push ${{ matrix.name }}
name: Build and push sample images to ACR
if: github.event.action != 'closed'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: demo
path: ./demo/
tag: tutorial/demo
- name: webapp
path: ./demo/
tag: tutorial/webapp
- name: dapr-backend
path: ./quickstarts/dapr/nodeapp/
tag: quickstarts/dapr-backend
- name: dapr-frontend
path: ./quickstarts/dapr/ui/
tag: quickstarts/dapr-frontend
- name: aws-reference-app
path: ./reference-apps/aws/
tag: reference-apps/aws
- name: environment-variables
path: ./quickstarts/environment-variables/
tag: quickstarts/envvars
- name: volumes
path: ./quickstarts/volumes/
tag: quickstarts/volumes
- name: aws-sqs
path: ./reference-apps/aws-sqs/
tag: reference-apps/aws-sqs-sample
steps:
- name: Checkout code
uses: actions/[email protected]
Expand All @@ -63,10 +41,120 @@ jobs:
login-server: ${{ env.DOCKER_REGISTRY }}
username: '${{ secrets.AZURE_SP_DOCKER_USERNAME }}'
password: '${{ secrets.AZURE_SP_DOCKER_PASSWORD }}'
- name: Build ${{ matrix.name }}
run: docker build ${{ matrix.path }} -t "${{ env.DOCKER_REGISTRY }}/${{ matrix.tag }}:${{ env.VERSION }}"
- name: Push ${{ matrix.name }}
run: docker push "${{ env.DOCKER_REGISTRY }}/${{ matrix.tag }}:${{ env.VERSION }}"
- 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
uses: docker/build-push-action@v4
with:
context: ./reference-apps/aws-sqs/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.DOCKER_REGISTRY }}/reference-apps/aws-sqs-sample:${{ env.VERSION }}
build-container:
name: Build and push sample images to GHCR
if: github.event.action != 'closed'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/[email protected]
- 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
uses: docker/build-push-action@v4
with:
context: ./reference-apps/aws-sqs/
push: ${{ env.PUSH_IMAGE }}
tags: ${{ env.CONTAINER_REGISTRY }}/reference-apps/aws-sqs-sample:${{ 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:
name: Cleanup ${{ matrix.image }}
if: github.event.action == 'closed'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/issues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
ISSUE: ${{ github.event.issue.html_url }}
AUTHOR: ${{ github.actor }}
run: |
MEMBERS=$(gh api orgs/project-radius/teams/Radius-Preview/members | jq -r '.[] | .login')
ADMINS=$(gh api orgs/project-radius/teams/Radius-Admin/members | jq -r '.[] | .login')
MEMBERS=$(gh api orgs/radius-project/teams/Radius-Preview/members | jq -r '.[] | .login')
ADMINS=$(gh api orgs/radius-project/teams/Radius-Admin/members | jq -r '.[] | .login')
for USER in $MEMBERS; do
if [[ "$USER" == "$AUTHOR" ]]; then
ISADMIN=false
Expand Down
55 changes: 0 additions & 55 deletions .github/workflows/purge-aws-test-resources.yaml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release samples

on:
workflow_dispatch:
inputs:
version:
description: 'Radius version number to use (e.g. 0.22.0, 0.23.0-rc1)'
required: true
default: ''
type: string

env:
GITHUB_TOKEN: ${{ secrets.GH_RAD_CI_BOT_PAT }}
GITHUB_EMAIL: '[email protected]'
GITHUB_USER: 'Radius CI Bot'

jobs:
release-samples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
ref: edge
path: samples
- name: Configure git
run: |
git config --global user.email "${{ env.GITHUB_EMAIL }}"
git config --global user.name "${{ env.GITHUB_USER }}"
- name: Ensure inputs.version is valid semver
run: |
python ./samples/.github/scripts/validate_semver.py ${{ inputs.version }}
- name: Parse release channel
id: parse_release_channel
run: |
# CHANNEL is the major and minor version of the VERSION_NUMBER (e.g. 0.1)
CHANNEL="$(echo ${{ inputs.version }} | cut -d '.' -f 1,2)"
echo "channel=$CHANNEL" >> $GITHUB_OUTPUT
- name: Release samples
run: |
./samples/.github/scripts/release-samples.sh ${{ inputs.version }}
- name: Change the default branch
run: |
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/radius-project/samples \
-f default_branch='v${{ steps.parse_release_channel.outputs.channel }}'
Loading

0 comments on commit 4b9991c

Please sign in to comment.