Skip to content

Commit

Permalink
build: dynamic fetch upstream build (#2316)
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 authored Jul 20, 2024
1 parent 066ee10 commit fffb8da
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ jobs:
BUILD_DATE=${BUILD_DATE} TEST_EXISTING_KEDA=${TEST_EXISTING_KEDA} make chart_cluster_setup
- run:
name: "Build Docker images"
no_output_timeout: 30m
command: |
N=3
while [ $N -gt 0 ]; do
Expand All @@ -254,6 +255,7 @@ jobs:
source $BASH_ENV
- run:
name: "Test Selenium Grid on Kubernetes"
no_output_timeout: 30m
command: |
N=3
while [ $N -gt 0 ]; do
Expand Down
40 changes: 40 additions & 0 deletions .github/actions/get-latest-upstream/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Get Latest Upstream
description: Get the latest upstream release of Selenium
inputs:
release:
description: 'Test a new release process'
required: false
type: boolean
default: false
gh_cli_token:
description: 'GitHub CLI authentication token'
required: true
type: secret

runs:
using: "composite"
steps:
- name: Get latest upstream
shell: bash
run: |
sudo apt update
sudo apt install gh
echo "${{ inputs.gh_cli_token }}" | gh auth login --with-token
if [ "${{ inputs.release }}" = "true" ]; then
echo "Getting the latest stable release."
RELEASE=$(gh release list -R SeleniumHQ/selenium | grep -v nightly | awk '{ print $4 }' | head -1)
else
echo "Getting the latest Nightly release."
RELEASE=$(gh release list -R SeleniumHQ/selenium | grep nightly | awk '{ print $3 }' | head -1)
if [ -z "${RELEASE}" ]; then
echo "Nightly release not found, getting the latest stable release."
RELEASE=$(gh release list -R SeleniumHQ/selenium | grep -v nightly | awk '{ print $4 }' | head -1)
fi
fi
jar_file=$(gh release view -R SeleniumHQ/selenium ${RELEASE} | grep jar | awk '{ print $2 }' | tail -n 1)
echo "Server package: ${jar_file}"
VERSION=$(echo $jar_file | sed 's/selenium-server-//;s/\.jar//')
echo "BASE_RELEASE=${RELEASE} | BASE_VERSION=${VERSION} | VERSION=${VERSION}"
echo "BASE_RELEASE=${RELEASE}" >> $GITHUB_ENV
echo "BASE_VERSION=${VERSION}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> $GITHUB_ENV
7 changes: 5 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
release:
description: 'Test a new release process'
required: false
type: boolean
default: false
type: string
default: 'false'
workflow_dispatch:
inputs:
rerunFailedOnly:
Expand All @@ -32,16 +32,19 @@ env:

jobs:
docker-test:
name: Test Seleium Grid on Docker
uses: ./.github/workflows/docker-test.yml
with:
release: ${{ inputs.release == 'true' }}

helm-chart-test:
name: Test Selenium Grid on Kubernetes
uses: ./.github/workflows/helm-chart-test.yml
with:
release: ${{ inputs.release == 'true' }}

rerun-workflow-when-failure:
name: Rerun workflow when failure
needs:
- docker-test
- helm-chart-test
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
release:
description: 'Deploy a new release'
required: false
type: boolean
default: false
type: string
default: 'true'
skip-test:
description: 'Skip the tests'
required: false
Expand All @@ -24,16 +24,17 @@ on:

jobs:
build-test:
name: Build and Test
if: contains(toJson(github.event.commits), '[deploy]') == true || (github.event_name == 'workflow_dispatch' && github.event.inputs.skip-test == 'false')
uses: ./.github/workflows/build-test.yml
with:
release: ${{ github.event.inputs.release == 'true' }}
release: ${{ github.event.inputs.release || true }}

deploy:
needs:
- build-test
if: (contains(toJson(github.event.commits), '[deploy]') || (github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true')) && !failure() && !cancelled()
name: Deploy Docker images
name: Deploy and Release
runs-on: ubuntu-latest
permissions: write-all
steps:
Expand All @@ -57,6 +58,11 @@ jobs:
make set_containerd_image_store
- name: Output Docker info
run: docker info
- name: Set Selenium base version
uses: ./.github/actions/get-latest-upstream
with:
release: ${{ github.event.inputs.release || true }}
gh_cli_token: ${{ secrets.GITHUB_TOKEN }}
- name: Sets build date
run: |
echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
release:
description: 'Test a new release process'
required: false
type: boolean
default: false
type: string
default: 'false'
workflow_dispatch:
inputs:
request-timeout:
Expand Down Expand Up @@ -100,10 +100,10 @@ jobs:
- name: Output branch name
run: echo ${BRANCH}
- name: Set Selenium base version
if: inputs.release != 'true'
run: |
make set_build_nightly
cat .env | xargs -I {} echo {} >> $GITHUB_ENV
uses: ./.github/actions/get-latest-upstream
with:
release: ${{ inputs.release || false }}
gh_cli_token: ${{ secrets.GITHUB_TOKEN }}
- name: Sets build date
run: |
echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/helm-chart-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ on:
release:
description: 'Deploy a new release'
required: false
type: boolean
default: false
type: string
default: 'false'

jobs:
helm-chart-test:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/helm-chart-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
release:
description: 'Test a new release process'
required: false
type: boolean
default: false
type: string
default: 'false'
workflow_dispatch:
inputs:
request-timeout:
Expand Down Expand Up @@ -108,10 +108,10 @@ jobs:
- name: Output branch name
run: echo ${BRANCH}
- name: Set Selenium base version
if: inputs.release != 'true'
run: |
make set_build_nightly
cat .env | xargs -I {} echo {} >> $GITHUB_ENV
uses: ./.github/actions/get-latest-upstream
with:
release: ${{ inputs.release || false }}
gh_cli_token: ${{ secrets.GITHUB_TOKEN }}
- name: Sets build date
run: |
echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:

jobs:
build-test:
name: Build and Test Nightly
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.skip-test == 'false')
uses: ./.github/workflows/build-test.yml
with:
Expand All @@ -21,7 +22,7 @@ jobs:
needs:
- build-test
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && !failure() && !cancelled()
name: Nightly build
name: Deploy and Release Nightly
runs-on: ubuntu-latest
permissions: write-all
steps:
Expand All @@ -45,6 +46,11 @@ jobs:
make set_containerd_image_store
- name: Output Docker info
run: docker info
- name: Set Selenium base version
uses: ./.github/actions/get-latest-upstream
with:
release: false
gh_cli_token: ${{ secrets.GITHUB_TOKEN }}
- name: Sets build date
run: |
echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV
Expand All @@ -59,7 +65,7 @@ jobs:
NAMESPACE: ${{ vars.DOCKER_NAMESPACE || 'selenium' }}
AUTHORS: ${{ vars.AUTHORS || 'SeleniumHQ' }}
- name: Build base image to get Grid version
run: VERSION="local" BUILD_DATE=${BUILD_DATE} make base_nightly
run: VERSION="local" BUILD_DATE=${BUILD_DATE} make base
- name: Get Grid version
# sed used to remove last comma of Selenium version output
run: |
Expand Down
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ ci: build test
base:
cd ./Base && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg VERSION=$(BASE_VERSION) --build-arg RELEASE=$(BASE_RELEASE) --build-arg AUTHORS=$(AUTHORS) -t $(NAME)/base:$(TAG_VERSION) .

base_nightly:
cd ./Base && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg VERSION=$(BASE_VERSION_NIGHTLY) --build-arg RELEASE=$(BASE_RELEASE_NIGHTLY) --build-arg AUTHORS=$(AUTHORS) -t $(NAME)/base:$(TAG_VERSION) .

hub: base
cd ./Hub && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/hub:$(TAG_VERSION) .

Expand Down

0 comments on commit fffb8da

Please sign in to comment.