Create Github Actions job for Kind cluster testing #139
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
# | |
# Copyright 2021 The Dapr 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. | |
# | |
name: dapr-ambient-init | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
permissions: | |
contents: write | |
jobs: | |
build: | |
name: "Build artifacts on ubuntu" | |
runs-on: ubuntu-latest | |
env: | |
GOOS: "${{ matrix.target_os }}" | |
GOARCH: "${{ matrix.target_arch }}" | |
GOPROXY: "https://proxy.golang.org" | |
ARCHIVE_OUTDIR: "dist/archives" | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
with: | |
image: tonistiigi/binfmt:latest | |
platforms: arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
version: v0.10.1 # Don't use latest since it broke our workflow once | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
id: setup-go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: "go.mod" | |
- name: Parse release version and set REL_VERSION and LATEST_RELEASE | |
run: python ./.github/scripts/get_release_version.py ${{ github.event_name }} | |
- name: Updates version | |
run: | | |
echo "REL_VERSION=${REL_VERSION}" >>${GITHUB_ENV} | |
echo "BINARIES=daprd" >>${GITHUB_ENV} | |
shell: bash | |
- name: Set REPO_OWNER | |
run: | | |
REPO_OWNER=${{ github.repository_owner }} | |
# Lowercase the value | |
echo "REPO_OWNER=${REPO_OWNER,,}" >>${GITHUB_ENV} | |
mkdir -p ${{ env.ARCHIVE_OUTDIR }} | |
shell: bash | |
- name: Run make release to build and archive binaries | |
run: | | |
make release | |
shell: bash | |
- name: Copy out file from volume | |
run: | | |
sudo cp ./ambient-init ${{ env.ARCHIVE_OUTDIR }}/ambient-init | |
- name: upload artifacts | |
uses: actions/upload-artifact@master | |
with: | |
name: ambient-init | |
path: ${{ env.ARCHIVE_OUTDIR }} | |
test: | |
name: "Test artifacts on Kind cluster" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
- name: Install kubectl | |
run: | | |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | |
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl | |
kubectl version --client --output=yaml | |
- name: Create k8s Kind Cluster | |
uses: helm/kind-action@v1.5.0 | |
- name: Setup helm | |
run: | | |
curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null | |
sudo apt-get install apt-transport-https --yes | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list | |
sudo apt-get update | |
sudo apt-get install helm | |
- name: Install dapr chart | |
run: | | |
kubectl config use-context kind-chart-testing | |
helm repo add dapr https://dapr.github.io/helm-charts/ | |
helm repo update | |
helm upgrade --install dapr dapr/dapr \ | |
--version=1.11 \ | |
--namespace dapr-system \ | |
--create-namespace \ | |
--wait | |
- name: Install ambient chart | |
run: | | |
helm install dapr-ambient chart/dapr-ambient \ | |
--set ambient.appId=my-dapr-app \ | |
--set ambient.remoteURL=subscriber-svc \ | |
--set ambient.remotePort=80 \ | |
--dry-run | |
helm install dapr-ambient chart/dapr-ambient \ | |
--set ambient.appId=my-dapr-app \ | |
--set ambient.remoteURL=subscriber-svc \ | |
--set ambient.remotePort=80 | |
publish: | |
name: Publish binaries | |
needs: build | |
if: github.event_name != 'pull_request' | |
env: | |
ARCHIVE_OUTDIR: "dist/archives" | |
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }} | |
ARTIFACT_DIR: ./release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
- name: Parse release version and set REL_VERSION and LATEST_RELEASE | |
run: python ./.github/scripts/get_release_version.py ${{ github.event_name }} | |
- name: Set REPO_OWNER | |
shell: bash | |
run: | | |
REPO_OWNER=${{ github.repository_owner }} | |
# Lowercase the value | |
echo "REPO_OWNER=${REPO_OWNER,,}" >>${GITHUB_ENV} | |
- name: "download artifact: ambient-init" | |
uses: actions/download-artifact@master | |
with: | |
name: ambient-init | |
path: ${{ env.ARCHIVE_OUTDIR }} | |
- name: generate checksum files | |
run: cd ${{ env.ARCHIVE_OUTDIR }} && for i in *; do sha256sum -b $i > "$i.sha256"; done && cd - | |
- name: publish binaries to github | |
if: startswith(github.ref, 'refs/tags/v') | |
run: | | |
echo "installing github-release-cli..." | |
sudo npm install --silent --no-progress -g github-release-cli@2.1.0 | |
if [ "$LATEST_RELEASE" = "true" ]; then | |
export RELEASE_BODY=`cat ./docs/release_notes/v${REL_VERSION}.md` | |
else | |
export RELEASE_BODY="This is the release candidate ${REL_VERSION}" | |
fi | |
# Get the list of files | |
RELEASE_ARTIFACT=(${{ env.ARCHIVE_OUTDIR }}/*) | |
# Parse repository to get owner and repo names | |
OWNER_NAME="${GITHUB_REPOSITORY%%/*}" | |
REPO_NAME="${GITHUB_REPOSITORY#*/}" | |
export GITHUB_TOKEN=${{ secrets.DAPR_BOT_TOKEN }} | |
echo "Uploading Dapr-Ambient Runtime Binaries to GitHub Release" | |
github-release upload \ | |
--owner $OWNER_NAME \ | |
--repo $REPO_NAME \ | |
--tag "v${REL_VERSION}" \ | |
--release-name "Dapr-Ambient Runtime v${REL_VERSION}" \ | |
--body "${RELEASE_BODY}" \ | |
--prerelease true \ | |
${RELEASE_ARTIFACT[*]} | |
shell: bash | |
docker-publish: | |
name: Publish docker images | |
needs: build | |
if: github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
- name: Parse release version and set REL_VERSION and LATEST_RELEASE | |
run: python ./.github/scripts/get_release_version.py ${{ github.event_name }} | |
- name: Set REPO_OWNER | |
shell: bash | |
run: | | |
REPO_OWNER=${{ github.repository_owner }} | |
# Lowercase the value | |
echo "REPO_OWNER=${REPO_OWNER,,}" >>${GITHUB_ENV} | |
- name: Container Registry login | |
uses: docker/login-action@v2 | |
env: | |
DOCKER_REGISTRY_ID: ${{ vars.DOCKER_DAPRIO_REGISTRY }} | |
with: | |
username: ${{ secrets.DOCKER_REGISTRY_ID }} | |
password: ${{ secrets.DOCKER_REGISTRY_PASS }} | |
- uses: ko-build/setup-ko@v0.6 | |
- name: Build & Push Images | |
env: | |
KO_DOCKER_REPO: ${{ vars.DOCKER_DAPRIO_REGISTRY }}/dapr-ambient | |
run: | | |
ko build cmd/ambient-init/main.go --platform=linux/amd64,linux/arm64 --tags ${REL_VERSION} --bare | |
helm: | |
runs-on: ubuntu-latest | |
if: github.event_name != 'pull_request' | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Parse release version and set REL_VERSION and LATEST_RELEASE | |
run: python ./.github/scripts/get_release_version.py ${{ github.event_name }} | |
- name: setup helm | |
run: | | |
curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null | |
sudo apt-get install apt-transport-https --yes | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list | |
sudo apt-get update | |
sudo apt-get install helm | |
- name: install helm | |
run: helm plugin install https://github.com/quintush/helm-unittest | |
- name: execute unit tests | |
run: helm unittest chart/dapr-ambient | |
- name: Update init-container tag | |
run: | | |
sed -i -e "s|tag: latest|tag: ${REL_VERSION}|g" ./chart/dapr-ambient/values.yaml | |
cat ./chart/dapr-ambient/values.yaml | |
- name: Container Registry login | |
uses: docker/login-action@v2 | |
env: | |
DOCKER_REGISTRY_ID: ${{ secrets.DOCKER_REGISTRY_ID }} | |
with: | |
username: ${{ secrets.DOCKER_REGISTRY_ID }} | |
password: ${{ secrets.DOCKER_REGISTRY_PASS }} | |
- name: Package & Push Helm Chart | |
run : | | |
helm package \ | |
./chart/dapr-ambient \ | |
--version ${REL_VERSION} | |
helm push dapr-ambient-chart-${REL_VERSION}.tgz oci://docker.io/${{ vars.DOCKER_DAPRIO_REGISTRY }} | |
shell: bash |