Skip to content

Commit fffb8da

Browse files
authored
build: dynamic fetch upstream build (#2316)
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 066ee10 commit fffb8da

File tree

9 files changed

+79
-25
lines changed

9 files changed

+79
-25
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ jobs:
231231
BUILD_DATE=${BUILD_DATE} TEST_EXISTING_KEDA=${TEST_EXISTING_KEDA} make chart_cluster_setup
232232
- run:
233233
name: "Build Docker images"
234+
no_output_timeout: 30m
234235
command: |
235236
N=3
236237
while [ $N -gt 0 ]; do
@@ -254,6 +255,7 @@ jobs:
254255
source $BASH_ENV
255256
- run:
256257
name: "Test Selenium Grid on Kubernetes"
258+
no_output_timeout: 30m
257259
command: |
258260
N=3
259261
while [ $N -gt 0 ]; do
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Get Latest Upstream
2+
description: Get the latest upstream release of Selenium
3+
inputs:
4+
release:
5+
description: 'Test a new release process'
6+
required: false
7+
type: boolean
8+
default: false
9+
gh_cli_token:
10+
description: 'GitHub CLI authentication token'
11+
required: true
12+
type: secret
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Get latest upstream
18+
shell: bash
19+
run: |
20+
sudo apt update
21+
sudo apt install gh
22+
echo "${{ inputs.gh_cli_token }}" | gh auth login --with-token
23+
if [ "${{ inputs.release }}" = "true" ]; then
24+
echo "Getting the latest stable release."
25+
RELEASE=$(gh release list -R SeleniumHQ/selenium | grep -v nightly | awk '{ print $4 }' | head -1)
26+
else
27+
echo "Getting the latest Nightly release."
28+
RELEASE=$(gh release list -R SeleniumHQ/selenium | grep nightly | awk '{ print $3 }' | head -1)
29+
if [ -z "${RELEASE}" ]; then
30+
echo "Nightly release not found, getting the latest stable release."
31+
RELEASE=$(gh release list -R SeleniumHQ/selenium | grep -v nightly | awk '{ print $4 }' | head -1)
32+
fi
33+
fi
34+
jar_file=$(gh release view -R SeleniumHQ/selenium ${RELEASE} | grep jar | awk '{ print $2 }' | tail -n 1)
35+
echo "Server package: ${jar_file}"
36+
VERSION=$(echo $jar_file | sed 's/selenium-server-//;s/\.jar//')
37+
echo "BASE_RELEASE=${RELEASE} | BASE_VERSION=${VERSION} | VERSION=${VERSION}"
38+
echo "BASE_RELEASE=${RELEASE}" >> $GITHUB_ENV
39+
echo "BASE_VERSION=${VERSION}" >> $GITHUB_ENV
40+
echo "VERSION=${VERSION}" >> $GITHUB_ENV

.github/workflows/build-test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ on:
66
release:
77
description: 'Test a new release process'
88
required: false
9-
type: boolean
10-
default: false
9+
type: string
10+
default: 'false'
1111
workflow_dispatch:
1212
inputs:
1313
rerunFailedOnly:
@@ -32,16 +32,19 @@ env:
3232

3333
jobs:
3434
docker-test:
35+
name: Test Seleium Grid on Docker
3536
uses: ./.github/workflows/docker-test.yml
3637
with:
3738
release: ${{ inputs.release == 'true' }}
3839

3940
helm-chart-test:
41+
name: Test Selenium Grid on Kubernetes
4042
uses: ./.github/workflows/helm-chart-test.yml
4143
with:
4244
release: ${{ inputs.release == 'true' }}
4345

4446
rerun-workflow-when-failure:
47+
name: Rerun workflow when failure
4548
needs:
4649
- docker-test
4750
- helm-chart-test

.github/workflows/deploy.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ on:
66
release:
77
description: 'Deploy a new release'
88
required: false
9-
type: boolean
10-
default: false
9+
type: string
10+
default: 'true'
1111
skip-test:
1212
description: 'Skip the tests'
1313
required: false
@@ -24,16 +24,17 @@ on:
2424

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

3233
deploy:
3334
needs:
3435
- build-test
3536
if: (contains(toJson(github.event.commits), '[deploy]') || (github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true')) && !failure() && !cancelled()
36-
name: Deploy Docker images
37+
name: Deploy and Release
3738
runs-on: ubuntu-latest
3839
permissions: write-all
3940
steps:
@@ -57,6 +58,11 @@ jobs:
5758
make set_containerd_image_store
5859
- name: Output Docker info
5960
run: docker info
61+
- name: Set Selenium base version
62+
uses: ./.github/actions/get-latest-upstream
63+
with:
64+
release: ${{ github.event.inputs.release || true }}
65+
gh_cli_token: ${{ secrets.GITHUB_TOKEN }}
6066
- name: Sets build date
6167
run: |
6268
echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV

.github/workflows/docker-test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ on:
66
release:
77
description: 'Test a new release process'
88
required: false
9-
type: boolean
10-
default: false
9+
type: string
10+
default: 'false'
1111
workflow_dispatch:
1212
inputs:
1313
request-timeout:
@@ -100,10 +100,10 @@ jobs:
100100
- name: Output branch name
101101
run: echo ${BRANCH}
102102
- name: Set Selenium base version
103-
if: inputs.release != 'true'
104-
run: |
105-
make set_build_nightly
106-
cat .env | xargs -I {} echo {} >> $GITHUB_ENV
103+
uses: ./.github/actions/get-latest-upstream
104+
with:
105+
release: ${{ inputs.release || false }}
106+
gh_cli_token: ${{ secrets.GITHUB_TOKEN }}
107107
- name: Sets build date
108108
run: |
109109
echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV

.github/workflows/helm-chart-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ on:
1313
release:
1414
description: 'Deploy a new release'
1515
required: false
16-
type: boolean
17-
default: false
16+
type: string
17+
default: 'false'
1818

1919
jobs:
2020
helm-chart-test:

.github/workflows/helm-chart-test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ on:
66
release:
77
description: 'Test a new release process'
88
required: false
9-
type: boolean
10-
default: false
9+
type: string
10+
default: 'false'
1111
workflow_dispatch:
1212
inputs:
1313
request-timeout:
@@ -108,10 +108,10 @@ jobs:
108108
- name: Output branch name
109109
run: echo ${BRANCH}
110110
- name: Set Selenium base version
111-
if: inputs.release != 'true'
112-
run: |
113-
make set_build_nightly
114-
cat .env | xargs -I {} echo {} >> $GITHUB_ENV
111+
uses: ./.github/actions/get-latest-upstream
112+
with:
113+
release: ${{ inputs.release || false }}
114+
gh_cli_token: ${{ secrets.GITHUB_TOKEN }}
115115
- name: Sets build date
116116
run: |
117117
echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV

.github/workflows/nightly.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212

1313
jobs:
1414
build-test:
15+
name: Build and Test Nightly
1516
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.skip-test == 'false')
1617
uses: ./.github/workflows/build-test.yml
1718
with:
@@ -21,7 +22,7 @@ jobs:
2122
needs:
2223
- build-test
2324
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && !failure() && !cancelled()
24-
name: Nightly build
25+
name: Deploy and Release Nightly
2526
runs-on: ubuntu-latest
2627
permissions: write-all
2728
steps:
@@ -45,6 +46,11 @@ jobs:
4546
make set_containerd_image_store
4647
- name: Output Docker info
4748
run: docker info
49+
- name: Set Selenium base version
50+
uses: ./.github/actions/get-latest-upstream
51+
with:
52+
release: false
53+
gh_cli_token: ${{ secrets.GITHUB_TOKEN }}
4854
- name: Sets build date
4955
run: |
5056
echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV
@@ -59,7 +65,7 @@ jobs:
5965
NAMESPACE: ${{ vars.DOCKER_NAMESPACE || 'selenium' }}
6066
AUTHORS: ${{ vars.AUTHORS || 'SeleniumHQ' }}
6167
- name: Build base image to get Grid version
62-
run: VERSION="local" BUILD_DATE=${BUILD_DATE} make base_nightly
68+
run: VERSION="local" BUILD_DATE=${BUILD_DATE} make base
6369
- name: Get Grid version
6470
# sed used to remove last comma of Selenium version output
6571
run: |

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ ci: build test
7070
base:
7171
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) .
7272

73-
base_nightly:
74-
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) .
75-
7673
hub: base
7774
cd ./Hub && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/hub:$(TAG_VERSION) .
7875

0 commit comments

Comments
 (0)