diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 91cf6dcd2c..0b7043f71b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -44,7 +44,7 @@ env: GHCR_ACTOR: rad-ci-bot # Container registry url for GitHub container registry. - CONTAINER_REGISTRY: ${{ github.event_name == 'pull_request' && 'ghcr.io/radius-project/dev' || 'ghcr.io/radius-project' }} + CONTAINER_REGISTRY: 'ghcr.io/radius-project' # Local file path to the release binaries. RELEASE_PATH: ./release @@ -254,10 +254,10 @@ jobs: env: DOCKER_REGISTRY: ${{ env.CONTAINER_REGISTRY }} DOCKER_TAG_VERSION: latest - - name: Push container images (PR) + - name: Build container images (PR) # Don't push on PR, agent will not have permission. run: | - make docker-test-image-build && make docker-test-image-push - make docker-multi-arch-push + make docker-test-image-build + make docker-multi-arch-build if: github.event_name == 'pull_request' env: DOCKER_REGISTRY: ${{ env.CONTAINER_REGISTRY }} @@ -275,13 +275,16 @@ jobs: name: Helm chart build needs: ['build-and-push-images'] runs-on: ubuntu-latest + # Don't push on PR, agent will not have permission. + if: (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') env: ARTIFACT_DIR: ./dist/Charts HELM_PACKAGE_DIR: helm HELM_CHARTS_DIR: deploy/Chart OCI_REGISTRY: ghcr.io - # If we are pushing from a tag or from the main branch, push to radius-project/helm-chart. Otherwise, push to radius-project/dev/helm-chart. - OCI_REPOSITORY: ${{ (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'radius-project/helm-chart' || 'radius-project/dev/helm-chart' }} + # We only push the chart on pushes to main or to a tag. The versioning logic will select the right + # version for us. + OCI_REPOSITORY: 'radius-project/helm-chart' steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 4e3ff81bcb..c6e1066494 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -35,6 +35,7 @@ jobs: env: GOVER: '^1.21' GOPROXY: https://proxy.golang.org + HELM_CHARTS_DIR: deploy/Chart steps: - name: Check out repo uses: actions/checkout@v3 @@ -59,8 +60,13 @@ jobs: run: go install github.com/golang/mock/mockgen@v1.5.0 - name: Install controller-gen run: go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.1 - - name: Setup Azure CLI - run: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash + - name: Install helm + uses: Azure/setup-helm@v3 + with: + version: 'v3.11.1' + - name: Run Helm linter + run: | + helm lint ${{ env.HELM_CHARTS_DIR }} - name: Run linter uses: golangci/golangci-lint-action@v3 with: diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index 6df36b7d84..bc91f0e948 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -6,12 +6,6 @@ on: branches: - main - release/* - pull_request: - types: [opened, synchronize, reopened, closed] - branches: - - main - - release/* - jobs: cli-docs: name: Generate CLI reference docs @@ -58,7 +52,6 @@ jobs: path: docs/docs/content/reference/cli - name: Create pull request uses: peter-evans/create-pull-request@v5 - if: github.event_name != 'pull_request' with: token: ${{ secrets.GH_RAD_CI_BOT_PAT }} path: docs diff --git a/.github/workflows/validate-bicep.yaml b/.github/workflows/validate-bicep.yaml index 9b1d4c7681..6546928b4a 100644 --- a/.github/workflows/validate-bicep.yaml +++ b/.github/workflows/validate-bicep.yaml @@ -33,37 +33,14 @@ jobs: steps: - name: Check out repo uses: actions/checkout@v3 - - - name: Clone docs repo - uses: actions/checkout@v3 - with: - token: ${{ secrets.GH_RAD_CI_BOT_PAT }} - repository: radius-project/docs - path: temp/radius-project/docs - ref: edge - - name: Clone samples repo - uses: actions/checkout@v3 - with: - token: ${{ secrets.GH_RAD_CI_BOT_PAT }} - repository: radius-project/samples - path: temp/radius-project/samples - ref: edge - - name: Setup Azure CLI - run: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash - - name: az CLI login - run: | - az login --service-principal \ - --username ${{ secrets.AZURE_SP_TESTS_APPID }} \ - --password ${{ secrets.AZURE_SP_TESTS_PASSWORD }} \ - --tenant ${{ secrets.AZURE_SP_TESTS_TENANTID }} - name: Parse release version and set environment variables run: python ./.github/scripts/get_release_version.py - - name: Download rad-bicep-corerp + - name: Download rad-bicep run: | - ./.github/scripts/curl-with-retries.sh https://get.radapp.dev/tools/bicep-extensibility/${{ env.REL_CHANNEL }}/linux-x64/rad-bicep --output rad-bicep-corerp - chmod +x rad-bicep-corerp - ./rad-bicep-corerp --version + ./.github/scripts/curl-with-retries.sh https://get.radapp.dev/tools/bicep-extensibility/${{ env.REL_CHANNEL }}/linux-x64/rad-bicep --output rad-bicep + chmod +x rad-bicep + ./rad-bicep --version - name: Verify Bicep files run: ./build/validate-bicep.sh env: - BICEP_PATH: './rad-bicep-corerp' + BICEP_PATH: './rad-bicep' diff --git a/build/docker.mk b/build/docker.mk index b81e139909..20bbc27993 100644 --- a/build/docker.mk +++ b/build/docker.mk @@ -55,11 +55,27 @@ docker-push-$(1): endef define generateDockerMultiArches +.PHONY: docker-multi-arch-build-$(1) +docker-multi-arch-build-$(1): build-$(1)-linux-arm64 build-$(1)-linux-amd64 build-$(1)-linux-arm + @echo "$(ARROW) Building Go image $(DOCKER_REGISTRY)/$(1):$(DOCKER_TAG_VERSION)" + @cp -v $(3) $(OUT_DIR)/Dockerfile-$(1) + + cd $(OUT_DIR) && docker buildx build -f ./Dockerfile-$(1) \ + --platform linux/amd64,linux/arm64,linux/arm \ + -t $(DOCKER_REGISTRY)/$(1):$(DOCKER_TAG_VERSION) \ + --label org.opencontainers.image.source="$(IMAGE_SRC)" \ + --label org.opencontainers.image.description="$(1)" \ + --label org.opencontainers.image.version="$(REL_VERSION)" \ + --label org.opencontainers.image.revision="$(GIT_COMMIT)" \ + $(2) + .PHONY: docker-multi-arch-push-$(1) docker-multi-arch-push-$(1): build-$(1)-linux-arm64 build-$(1)-linux-amd64 build-$(1)-linux-arm - @echo "$(ARROW) Building Go image $(DOCKER_REGISTRY)/$(1):$(DOCKER_TAG_VERSION)" + @echo "$(ARROW) Building and pushing Go image $(DOCKER_REGISTRY)/$(1):$(DOCKER_TAG_VERSION)" @cp -v $(3) $(OUT_DIR)/Dockerfile-$(1) + # Building and pushing in one step is more efficient with buildx, so we duplicate the command + # to build and add --push. cd $(OUT_DIR) && docker buildx build -f ./Dockerfile-$(1) \ --platform linux/amd64,linux/arm64,linux/arm \ -t $(DOCKER_REGISTRY)/$(1):$(DOCKER_TAG_VERSION) \ @@ -67,7 +83,8 @@ docker-multi-arch-push-$(1): build-$(1)-linux-arm64 build-$(1)-linux-amd64 build --label org.opencontainers.image.description="$(1)" \ --label org.opencontainers.image.version="$(REL_VERSION)" \ --label org.opencontainers.image.revision="$(GIT_COMMIT)" \ - --push $(2) + --push \ + $(2) endef # configure-buildx is to initialize qemu and buildx environment. @@ -100,15 +117,18 @@ DOCKER_BUILD_TARGETS:=$(foreach IMAGE,$(DOCKER_IMAGES),docker-build-$(IMAGE)) # list of 'outputs' to push all images DOCKER_PUSH_TARGETS:=$(foreach IMAGE,$(DOCKER_IMAGES),docker-push-$(IMAGE)) +# list of 'outputs' to build all multi arch images +DOCKER_BUILD_MULTI_TARGETS:=$(foreach IMAGE,$(DOCKER_IMAGES),docker-multi-arch-build-$(IMAGE)) + # list of 'outputs' to push all multi arch images DOCKER_PUSH_MULTI_TARGETS:=$(foreach IMAGE,$(DOCKER_IMAGES),docker-multi-arch-push-$(IMAGE)) # targets to build test images .PHONY: docker-test-image-build -docker-test-image-build: docker-build-magpiego docker-build-testrp ## Builds all Docker images. +docker-test-image-build: docker-build-magpiego docker-build-testrp ## Builds all test Docker images. .PHONY: docker-test-image-push -docker-test-image-push: docker-push-magpiego docker-push-testrp ## Builds all Docker images. +docker-test-image-push: docker-push-magpiego docker-push-testrp ## Pushes all test Docker images. # targets to build development images .PHONY: docker-build @@ -119,5 +139,8 @@ docker-push: $(DOCKER_PUSH_TARGETS) docker-test-image-push ## Pushes all Docker # targets to build and push multi arch images. If you run this target in your machine, # ensure you have qemu and buildx installed by running make configure-buildx. +.PHONY: docker-multi-arch-build +docker-multi-arch-build: $(DOCKER_BUILD_MULTI_TARGETS) ## Builds all non-test docker images for multiple architectures. + .PHONY: docker-multi-arch-push -docker-multi-arch-push: $(DOCKER_PUSH_MULTI_TARGETS) ## Pushes all docker images after building. +docker-multi-arch-push: $(DOCKER_PUSH_MULTI_TARGETS) ## Pushes all non-test docker images for multiple architectures after building.