From 6daa77604cb14f2cab05f79c51cc852145d02584 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Thu, 11 Apr 2024 20:54:41 +0000 Subject: [PATCH] [build][test]: CI workflow is able fetch fork upstream artifacts via `vars.GH_ORG` Signed-off-by: Viet Nguyen Duc --- .github/workflows/build-test.yml | 4 +++- .github/workflows/deploy.yml | 1 + .github/workflows/helm-chart-test.yml | 4 +++- .github/workflows/nightly.yaml | 2 ++ .github/workflows/test-video.yml | 4 +++- Base/Dockerfile | 3 ++- Makefile | 6 ++++-- tests/docker-compose-v3-test-node-docker.yaml | 7 ++++--- 8 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 1cb566815..10ab23b0d 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -47,7 +47,9 @@ jobs: echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV make set_nightly_env cat .env | xargs -I {} echo {} >> $GITHUB_ENV - echo $BASE_RELEASE $BASE_VERSION + echo "GH_ORG=${GH_ORG}" >> $GITHUB_ENV + env: + GH_ORG: ${{ vars.GH_ORG || 'SeleniumHQ' }} - name: Build Docker images run: VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build - name: Test Docker images diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 82ee2a4b5..e11edf65c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,6 +27,7 @@ jobs: echo "NAME=${NAMESPACE}" >> $GITHUB_ENV env: NAMESPACE: ${{ vars.DOCKER_NAMESPACE || 'selenium' }} + GH_ORG: ${{ vars.GH_ORG || 'SeleniumHQ' }} - name: Sets prerelease to false by default run: echo "PRERELEASE=false" >> $GITHUB_ENV - name: Build base image to get Grid version diff --git a/.github/workflows/helm-chart-test.yml b/.github/workflows/helm-chart-test.yml index 681ddc28e..7ed9fd6a6 100644 --- a/.github/workflows/helm-chart-test.yml +++ b/.github/workflows/helm-chart-test.yml @@ -95,7 +95,9 @@ jobs: echo "IMAGE_REGISTRY=artifactory/selenium" >> $GITHUB_ENV make set_nightly_env cat .env | xargs -I {} echo {} >> $GITHUB_ENV - echo $BASE_RELEASE $BASE_VERSION + echo "GH_ORG=${GH_ORG}" >> $GITHUB_ENV + env: + GH_ORG: ${{ vars.GH_ORG || 'SeleniumHQ' }} - name: Setup Kubernetes environment uses: nick-invision/retry@master with: diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index 61574c38c..8f3fb9220 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -23,8 +23,10 @@ jobs: run: | echo "PRERELEASE=true" >> $GITHUB_ENV echo "NAME=${NAMESPACE}" >> $GITHUB_ENV + echo "GH_ORG=${GH_ORG}" >> $GITHUB_ENV env: NAMESPACE: ${{ vars.DOCKER_NAMESPACE || 'selenium' }} + GH_ORG: ${{ vars.GH_ORG || 'SeleniumHQ' }} - name: Build base image to get Grid version run: VERSION="local" BUILD_DATE=${BUILD_DATE} make base_nightly - name: Get Grid version diff --git a/.github/workflows/test-video.yml b/.github/workflows/test-video.yml index 0ee0d8af7..536e846d0 100644 --- a/.github/workflows/test-video.yml +++ b/.github/workflows/test-video.yml @@ -63,7 +63,9 @@ jobs: echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV make set_nightly_env cat .env | xargs -I {} echo {} >> $GITHUB_ENV - echo $BASE_RELEASE $BASE_VERSION + echo "GH_ORG=${GH_ORG}" >> $GITHUB_ENV + env: + GH_ORG: ${{ vars.GH_ORG || 'SeleniumHQ' }} - name: Pre-build to reduce logs in test phase run: | VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make hub diff --git a/Base/Dockerfile b/Base/Dockerfile index 59f9f7583..47ae4af7f 100644 --- a/Base/Dockerfile +++ b/Base/Dockerfile @@ -4,6 +4,7 @@ LABEL authors="Selenium " # Arguments to define the version of dependencies to download ARG VERSION ARG RELEASE=selenium-${VERSION} +ARG GH_ORG=SeleniumHQ # Default value should be aligned with upstream Selenium (https://github.com/SeleniumHQ/selenium/blob/trunk/java/maven_deps.bzl) ARG OPENTELEMETRY_VERSION=1.36.0 ARG GRPC_VERSION=1.62.2 @@ -117,7 +118,7 @@ RUN mkdir -p /opt/selenium /opt/selenium/assets /var/run/supervisor /var/log/sup && touch /opt/selenium/config.toml \ && chown -R ${SEL_USER}:${SEL_GROUP} /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd ${HOME} \ && chmod -R 775 /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd ${HOME} \ - && wget --no-verbose https://github.com/SeleniumHQ/selenium/releases/download/${RELEASE}/selenium-server-${VERSION}.jar \ + && wget --no-verbose https://github.com/${GH_ORG}/selenium/releases/download/${RELEASE}/selenium-server-${VERSION}.jar \ -O /opt/selenium/selenium-server.jar \ && echo "${SEL_PASSWD}" > /opt/selenium/initialPasswd \ && chgrp -R 0 /opt/selenium ${HOME} /opt/selenium/assets /var/run/supervisor /var/log/supervisor \ diff --git a/Makefile b/Makefile index 36ef28d9f..340dc0f11 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ NAME := $(or $(NAME),$(NAME),selenium) CURRENT_DATE := $(shell date '+%Y%m%d') BUILD_DATE := $(or $(BUILD_DATE),$(BUILD_DATE),$(CURRENT_DATE)) +GH_ORG := $(or $(GH_ORG),$(GH_ORG),SeleniumHQ) BASE_RELEASE := $(or $(BASE_RELEASE),$(BASE_RELEASE),selenium-4.19.0) BASE_VERSION := $(or $(BASE_VERSION),$(BASE_VERSION),4.19.1) BINDING_VERSION := $(or $(BINDING_VERSION),$(BINDING_VERSION),4.19.0) @@ -49,10 +50,10 @@ build: all ci: build test base: - cd ./Base && docker build $(BUILD_ARGS) --build-arg VERSION=$(BASE_VERSION) --build-arg RELEASE=$(BASE_RELEASE) -t $(NAME)/base:$(TAG_VERSION) . + cd ./Base && docker build $(BUILD_ARGS) --build-arg VERSION=$(BASE_VERSION) --build-arg RELEASE=$(BASE_RELEASE) --build-arg GH_ORG=$(GH_ORG) -t $(NAME)/base:$(TAG_VERSION) . base_nightly: - cd ./Base && docker build $(BUILD_ARGS) --build-arg VERSION=$(BASE_VERSION_NIGHTLY) --build-arg RELEASE=$(BASE_RELEASE_NIGHTLY) -t $(NAME)/base:$(TAG_VERSION) . + cd ./Base && docker build $(BUILD_ARGS) --build-arg VERSION=$(BASE_VERSION_NIGHTLY) --build-arg RELEASE=$(BASE_RELEASE_NIGHTLY) --build-arg GH_ORG=$(GH_ORG) -t $(NAME)/base:$(TAG_VERSION) . hub: base cd ./Hub && docker build $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/hub:$(TAG_VERSION) . @@ -448,6 +449,7 @@ test_node_docker: hub standalone_docker standalone_chrome standalone_firefox sta echo NODE=$$node >> .env ; \ echo UID=$$(id -u) >> .env ; \ echo BINDING_VERSION=$(BINDING_VERSION) >> .env ; \ + echo HOST_IP=$$(hostname -I | awk '{print $$1}') >> .env ; \ export $$(cat .env | xargs) ; \ envsubst < config.toml > ./videos/config.toml ; \ docker compose -f docker-compose-v3-test-node-docker.yaml up --no-log-prefix --exit-code-from tests --build ; \ diff --git a/tests/docker-compose-v3-test-node-docker.yaml b/tests/docker-compose-v3-test-node-docker.yaml index d8e433e60..025f83449 100644 --- a/tests/docker-compose-v3-test-node-docker.yaml +++ b/tests/docker-compose-v3-test-node-docker.yaml @@ -9,9 +9,10 @@ services: - /var/run/docker.sock:/var/run/docker.sock dns: - 8.8.8.8 - - 1.1.1.1 - dns_search: - - selenium-grid.local + - 8.8.4.4 + dns_search: selenium-grid.local + extra_hosts: + - "prod.domain.com:${HOST_IP}" depends_on: - selenium-hub environment: