Skip to content

Commit

Permalink
build(nightly): Add build image based on upstream Selenium Nightly (#…
Browse files Browse the repository at this point in the history
…2088)

Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 authored Jan 10, 2024
1 parent 7accd3f commit 6eca337
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 10 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Nightly
on:
workflow_dispatch:
inputs:
NAMESPACE:
description: 'Set image registry'
required: true
default: 'selenium'
schedule:
- cron: '0 1 * * *'

jobs:
deploy:
name: Nightly build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Output Docker info
run: docker info
- name: Sets build date
run: echo "BUILD_DATE=$(date '+%Y%m%d')" >> $GITHUB_ENV
- name: Sets prerelease to nightly
run: |
echo "PRERELEASE=true" >> $GITHUB_ENV
echo "NAME=${NAMESPACE}" >> $GITHUB_ENV
env:
NAMESPACE: ${{ github.event.inputs.NAMESPACE }}
- name: Build base image to get Grid version
run: VERSION="local" BUILD_DATE=${BUILD_DATE} make base_nightly
- name: Get Grid version
# sed used to remove last comma of Selenium version output
run: |
echo "GRID_VERSION=$(docker run --rm ${{ env.NAME }}/base:local-${BUILD_DATE} java -jar /opt/selenium/selenium-server.jar hub --version | awk '{print $3}' | sed 's/\(.*\),/\1 /')" | awk '{$1=$1;print}' >> $GITHUB_ENV
- name: Display Grid version and set Base version
run: |
echo ${GRID_VERSION}
echo "BASE_VERSION=$(echo ${GRID_VERSION})" >> $GITHUB_ENV
echo "BASE_RELEASE=nightly" >> $GITHUB_ENV
- name: Remove local Docker tag
run: docker rmi ${{ env.NAME }}/base:local-${BUILD_DATE}
- name: Build images
run: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make build
- name: Login Docker Hub
run: docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
env:
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
- name: Tag images as nightly
uses: nick-invision/retry@master
with:
timeout_minutes: 20
max_attempts: 3
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make tag_nightly
- name: Deploy nightly tag
uses: nick-invision/retry@master
with:
timeout_minutes: 20
max_attempts: 3
command: VERSION="${GRID_VERSION}" BUILD_DATE=${BUILD_DATE} make release_nightly
- name: Sets env var for the next tag
run: echo "NEXT_TAG=nightly" >> $GITHUB_ENV
- name: Get current latest tag
run: echo "LATEST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Display latest tag
run: echo ${LATEST_TAG}
- name: Create release notes (release_notes.md)
run: ./generate_release_notes.sh ${LATEST_TAG} origin/trunk ${GRID_VERSION} ${BUILD_DATE}
- name: Create Nightly Release
id: create_release
uses: ncipollo/release-action@main
with:
#artifacts:
replacesArtifacts: true
bodyFile: "release_notes.md"
generateReleaseNotes: true
name: Nightly
tag: nightly
allowUpdates: true
prerelease: ${{ env.PRERELEASE }}
47 changes: 45 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
NAME := $(or $(NAME),$(NAME),selenium)
CURRENT_DATE := $(shell date '+%Y%m%d')
BUILD_DATE := $(or $(BUILD_DATE),$(BUILD_DATE),$(CURRENT_DATE))
VERSION := $(or $(VERSION),$(VERSION),4.16.1)
BASE_VERSION := $(or $(BASE_VERSION),$(BASE_VERSION),4.16.1)
BASE_RELEASE := $(or $(BASE_RELEASE),$(BASE_RELEASE),selenium-4.16.0)
BASE_VERSION := $(or $(BASE_VERSION),$(BASE_VERSION),4.16.1)
BASE_RELEASE_NIGHTLY := $(or $(BASE_RELEASE_NIGHTLY),$(BASE_RELEASE_NIGHTLY),nightly)
BASE_VERSION_NIGHTLY := $(or $(BASE_VERSION_NIGHTLY),$(BASE_VERSION_NIGHTLY),4.17.0-SNAPSHOT)
VERSION := $(or $(VERSION),$(VERSION),$(BASE_VERSION))
TAG_VERSION := $(VERSION)-$(BUILD_DATE)
NAMESPACE := $(or $(NAMESPACE),$(NAMESPACE),$(NAME))
AUTHORS := $(or $(AUTHORS),$(AUTHORS),SeleniumHQ)
Expand Down Expand Up @@ -41,6 +43,9 @@ 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) .

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) .

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

Expand Down Expand Up @@ -177,6 +182,44 @@ release_latest:
docker push $(NAME)/standalone-docker:latest
docker push $(NAME)/video:latest

tag_nightly:
docker tag $(NAME)/base:$(TAG_VERSION) $(NAME)/base:nightly
docker tag $(NAME)/hub:$(TAG_VERSION) $(NAME)/hub:nightly
docker tag $(NAME)/distributor:$(TAG_VERSION) $(NAME)/distributor:nightly
docker tag $(NAME)/router:$(TAG_VERSION) $(NAME)/router:nightly
docker tag $(NAME)/sessions:$(TAG_VERSION) $(NAME)/sessions:nightly
docker tag $(NAME)/session-queue:$(TAG_VERSION) $(NAME)/session-queue:nightly
docker tag $(NAME)/event-bus:$(TAG_VERSION) $(NAME)/event-bus:nightly
docker tag $(NAME)/node-base:$(TAG_VERSION) $(NAME)/node-base:nightly
docker tag $(NAME)/node-chrome:$(TAG_VERSION) $(NAME)/node-chrome:nightly
docker tag $(NAME)/node-edge:$(TAG_VERSION) $(NAME)/node-edge:nightly
docker tag $(NAME)/node-firefox:$(TAG_VERSION) $(NAME)/node-firefox:nightly
docker tag $(NAME)/node-docker:$(TAG_VERSION) $(NAME)/node-docker:nightly
docker tag $(NAME)/standalone-chrome:$(TAG_VERSION) $(NAME)/standalone-chrome:nightly
docker tag $(NAME)/standalone-edge:$(TAG_VERSION) $(NAME)/standalone-edge:nightly
docker tag $(NAME)/standalone-firefox:$(TAG_VERSION) $(NAME)/standalone-firefox:nightly
docker tag $(NAME)/standalone-docker:$(TAG_VERSION) $(NAME)/standalone-docker:nightly
docker tag $(NAME)/video:$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) $(NAME)/video:nightly

release_nightly:
docker push $(NAME)/base:nightly
docker push $(NAME)/hub:nightly
docker push $(NAME)/distributor:nightly
docker push $(NAME)/router:nightly
docker push $(NAME)/sessions:nightly
docker push $(NAME)/session-queue:nightly
docker push $(NAME)/event-bus:nightly
docker push $(NAME)/node-base:nightly
docker push $(NAME)/node-chrome:nightly
docker push $(NAME)/node-edge:nightly
docker push $(NAME)/node-firefox:nightly
docker push $(NAME)/node-docker:nightly
docker push $(NAME)/standalone-chrome:nightly
docker push $(NAME)/standalone-edge:nightly
docker push $(NAME)/standalone-firefox:nightly
docker push $(NAME)/standalone-docker:nightly
docker push $(NAME)/video:nightly

tag_major_minor:
docker tag $(NAME)/base:$(TAG_VERSION) $(NAME)/base:$(MAJOR)
docker tag $(NAME)/hub:$(TAG_VERSION) $(NAME)/hub:$(MAJOR)
Expand Down
17 changes: 9 additions & 8 deletions generate_release_notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ LATEST_TAG=$1
HEAD_BRANCH=$2
GRID_VERSION=$3
BUILD_DATE=$4
NAMESPACE=${NAME:-selenium}

TAG_VERSION=${GRID_VERSION}-${BUILD_DATE}

echo "" >> release_notes.md
echo "### Changelog" > release_notes.md
git --no-pager log "${LATEST_TAG}...${HEAD_BRANCH}" --pretty=format:"* [\`%h\`](http://github.com/seleniumhq/docker-selenium/commit/%H) - %s :: %an" --reverse >> release_notes.md

CHROME_VERSION=$(docker run --rm selenium/node-chrome:${TAG_VERSION} google-chrome --version | awk '{print $3}')
EDGE_VERSION=$(docker run --rm selenium/node-edge:${TAG_VERSION} microsoft-edge --version | awk '{print $3}')
CHROMEDRIVER_VERSION=$(docker run --rm selenium/node-chrome:${TAG_VERSION} chromedriver --version | awk '{print $2}')
EDGEDRIVER_VERSION=$(docker run --rm selenium/node-edge:${TAG_VERSION} msedgedriver --version | awk '{print $4}')
FIREFOX_VERSION=$(docker run --rm selenium/node-firefox:${TAG_VERSION} firefox --version | awk '{print $3}')
GECKODRIVER_VERSION=$(docker run --rm selenium/node-firefox:${TAG_VERSION} geckodriver --version | awk 'NR==1{print $2}')
FFMPEG_VERSION=$(docker run --entrypoint="" --rm selenium/video:ffmpeg-6.1-${BUILD_DATE} ffmpeg -version | awk '{print $3}' | head -n 1)
CHROME_VERSION=$(docker run --rm ${NAMESPACE}/node-chrome:${TAG_VERSION} google-chrome --version | awk '{print $3}')
EDGE_VERSION=$(docker run --rm ${NAMESPACE}/node-edge:${TAG_VERSION} microsoft-edge --version | awk '{print $3}')
CHROMEDRIVER_VERSION=$(docker run --rm ${NAMESPACE}/node-chrome:${TAG_VERSION} chromedriver --version | awk '{print $2}')
EDGEDRIVER_VERSION=$(docker run --rm ${NAMESPACE}/node-edge:${TAG_VERSION} msedgedriver --version | awk '{print $4}')
FIREFOX_VERSION=$(docker run --rm ${NAMESPACE}/node-firefox:${TAG_VERSION} firefox --version | awk '{print $3}')
GECKODRIVER_VERSION=$(docker run --rm ${NAMESPACE}/node-firefox:${TAG_VERSION} geckodriver --version | awk 'NR==1{print $2}')
FFMPEG_VERSION=$(docker run --entrypoint="" --rm ${NAMESPACE}/video:ffmpeg-6.1-${BUILD_DATE} ffmpeg -version | awk '{print $3}' | head -n 1)


echo "" >> release_notes.md
Expand All @@ -37,7 +38,7 @@ echo "<details>" >> release_notes.md
echo "<summary>Click to see published Docker images</summary>" >> release_notes.md
echo "" >> release_notes.md
echo '```' >> release_notes.md
docker images --filter=reference='selenium/*:*' --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}\t{{.Size}}" >> release_notes.md
docker images --filter=reference=${NAMESPACE}'/*:*' --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}\t{{.Size}}" >> release_notes.md
echo '```' >> release_notes.md
echo "" >> release_notes.md
echo "</details>" >> release_notes.md
Expand Down

0 comments on commit 6eca337

Please sign in to comment.