diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml deleted file mode 100644 index e3545d75..00000000 --- a/.github/workflows/nodejs.yml +++ /dev/null @@ -1,207 +0,0 @@ -#name: Katalon Agent -# -#on: -# push: -# branches: -# - master -# pull_request: -# branches: -# - master -# release: -# types: -# - published - -#jobs: - ### BUILD ### -# build: -# name: Build -# -# runs-on: ${{ matrix.os }} -# -# strategy: -# fail-fast: true -# matrix: -# os: -# - ubuntu-latest -# - macos-latest -# - windows-latest -# node-version: -# - 10.x -# -# steps: -# - name: Checkout code -# uses: actions/checkout@v2.1.0 -# -# - name: Setup Node.js ${{ matrix.node-version }} -# uses: actions/setup-node@v2.1.2 -# with: -# node-version: ${{ matrix.node-version }} -# -# - name: Cache -# id: cache-packages -# uses: actions/cache@v1.1.2 -# with: -# path: node_modules -# key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} -# -# - name: Install packages -# if: steps.cache-packages.outputs.cache-hit != 'true' -# run: npm ci -# -# - name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }} -# env: -# CI: true -# if: ${{ matrix.os == 'ubuntu-latest' }} -# run: | -# npm run buildLinux --if-present -# chmod +x bin/cli-linux-x64 *.sh -# ls -l bin -# -# - name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }} -# env: -# CI: true -# if: ${{ matrix.os == 'macos-latest' }} -# run: | -# npm run buildMacos --if-present -# chmod +x bin/cli-macos-x64 *.sh -# ls -l bin -# -# - name: Build with Node.js ${{ matrix.node-version }} on ${{ runner.os }} -# env: -# CI: true -# if: ${{ matrix.os == 'windows-latest' }} -# run: npm run buildWin --if-present -# -# - name: Set BUILD_VERSION environment variable -# run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV -# shell: bash -# -# - name: Upload Windows x64 artifact -# uses: actions/upload-artifact@v2 -# if: ${{ matrix.os == 'windows-latest' }} -# with: -# name: katalon-agent-win-x64-${{ env.BUILD_VERSION }} -# path: | -# bin/cli-win-x64.exe -# bin/nssm.exe -# bin/*.bat -# -# - name: Upload Windows x86 artifact -# uses: actions/upload-artifact@v2 -# if: ${{ matrix.os == 'windows-latest' }} -# with: -# name: katalon-agent-win-x86-${{ env.BUILD_VERSION }} -# path: | -# bin/cli-win-x86.exe -# bin/nssm.exe -# bin/*.bat -# -# - name: Upload Linux x64 artifact -# uses: actions/upload-artifact@v2 -# if: ${{ matrix.os == 'ubuntu-latest' }} -# with: -# name: katalon-agent-linux-x64-${{ env.BUILD_VERSION }} -# path: | -# bin/cli-linux-x64 -# bin/*.sh -# -# - name: Upload MacOS x64 artifact -# uses: actions/upload-artifact@v2 -# if: ${{ matrix.os == 'macos-latest' }} -# with: -# name: katalon-agent-macos-x64-${{ env.BUILD_VERSION }} -# path: | -# bin/cli-macos-x64 -# bin/start.sh -# - ## RELEASE ### -# release: -# name: Draft new release -# -# needs: build -# -# runs-on: ubuntu-latest -# -# strategy: -# matrix: -# node-version: -# - 10.x -# -# steps: -# - name: Checkout code -# uses: actions/checkout@v2.1.0 -# -# - name: Setup Node.js ${{ matrix.node-version }} -# uses: actions/setup-node@v2.1.2 -# with: -# node-version: ${{ matrix.node-version }} -# -# - name: Cache -# id: cache-packages -# uses: actions/cache@v1.1.2 -# with: -# path: node_modules -# key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} -# -# - name: Install packages -# if: steps.cache-packages.outputs.cache-hit != 'true' -# run: npm install --only dev -# -# - name: Download artifacts -# uses: actions/download-artifact@v2 -# with: -# path: . -# -# - name: Add execute permission to downloaded artifacts -# run: chmod +x katalon-agent-linux-*/* katalon-agent-macos-*/* -# -# - name: Set BUILD_VERSION environment variable -# run: echo "BUILD_VERSION=$(node -p "require('./package').version")" >> $GITHUB_ENV -# -# - name: Package artifacts for release -# env: -# GZIP: -9 -# if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} -# run: | -# mkdir -p packages -# ls -la -# zip -9 -j packages/katalon-agent-win-x64-$BUILD_VERSION.zip katalon-agent-win-x64-$BUILD_VERSION/* -# zip -9 -j packages/katalon-agent-win-x86-$BUILD_VERSION.zip katalon-agent-win-x86-$BUILD_VERSION/* -# zip -9 -j packages/katalon-agent-linux-x64-$BUILD_VERSION.zip katalon-agent-linux-x64-$BUILD_VERSION/* -# zip -9 -j packages/katalon-agent-macos-x64-$BUILD_VERSION.zip katalon-agent-macos-x64-$BUILD_VERSION/* -# cd katalon-agent-linux-x64-$BUILD_VERSION -# tar cvzf ../packages/katalon-agent-linux-x64-$BUILD_VERSION.tar.gz * -# -# - name: Draft new release -# if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# run: npm run release -# - ## DEPLOY ### -# deploy: -# name: Deploy cloud agent -# -# needs: build -# -# runs-on: ubuntu-latest -# -# if: ${{ github.event_name == 'release' }} -# -# steps: -# - name: Download artifacts -# uses: actions/download-artifact@v2 -# with: -# path: . -# -# - name: Configure AWS Credentials -# uses: aws-actions/configure-aws-credentials@v1 -# with: -# aws-access-key-id: ${{ secrets.AWS_API_KEY }} -# aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} -# aws-region: us-east-1 -# -# - name: Deploy to s3 -# run: | -# ls -laR -# aws s3 cp katalon-agent-linux-x64-*/cli-linux-x64 s3://${{ secrets.AWS_S3_BUCKET }} diff --git a/.github/workflows/publish_agent_docker.yml b/.github/workflows/publish_agent_docker.yml index c048a6aa..f062555a 100644 --- a/.github/workflows/publish_agent_docker.yml +++ b/.github/workflows/publish_agent_docker.yml @@ -16,16 +16,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - - name: Sets tag for latest version - if: ${{ inputs.is-latest }} - run: | - echo "DOCKER_TAG_NAME=latest" >> $GITHUB_ENV - - - name: Sets tag for non-latest version - if: ${{ ! inputs.is-latest }} - run: | - echo "DOCKER_TAG_NAME=${{ inputs.version }}" >> $GITHUB_ENV + with: + ref: release - name: Login Docker Hub uses: docker/login-action@v1 @@ -44,4 +36,15 @@ jobs: build-args: AGENT_VERSION=${{ inputs.version }} builder: ${{ steps.buildx.outputs.name }} push: true - tags: katalonstudio/agent:${{ env.DOCKER_TAG_NAME }} \ No newline at end of file + tags: katalonstudio/agent:${{ inputs.version }} + + - name: Build and push Docker images + uses: docker/build-push-action@v2 + if: ${{ inputs.is-latest }} + with: + context: ./ + file: ./Dockerfile + build-args: AGENT_VERSION=${{ inputs.version }} + builder: ${{ steps.buildx.outputs.name }} + push: true + tags: katalonstudio/agent:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 000e487e..e8a7ec10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN chmod a+x ./docker/scripts/build_agent.sh RUN ./docker/scripts/build_agent.sh # Build docker image -FROM ubuntu:20.04 +FROM katalonstudio/katalon:8.6.5 # Agent arguement ARG AGENT_VERSION @@ -45,34 +45,29 @@ ENV XVFB_RUN='' ENV X11_DISPLAY='' ENV KEEP_FILES='' ENV NO_KEEP_FILES='' +ENV AUTO_UPGRADE_ENVIRONMENT=false +# PATH Environment +ENV PATH "$PATH:$KATALON_SCRIPT_DIR:$KATALON_AGENT_DIR:$GRADLE_BIN" +RUN echo "PATH=\"$PATH\"" > /etc/environment -# Copy script files -RUN apt update && apt -y install openjdk-8-jdk && update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java +# Copy agent +WORKDIR $KATALON_AGENT_DIR +COPY --from=build /katalon/bin/cli-linux-x64 *.sh ./ # Copy script files -RUN mkdir -p $KATALON_SCRIPT_DIR +# RUN apt update && apt -y install openjdk-8-jdk && update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java + +# Copy script files and setup WORKDIR $KATALON_SCRIPT_DIR -COPY ./docker/scripts/wrap_chrome_binary.sh wrap_chrome_binary.sh -COPY ./docker/scripts/setup_environment.sh setup_environment.sh +# COPY ./docker/scripts/wrap_chrome_binary.sh wrap_chrome_binary.sh +# COPY ./docker/scripts/setup_environment.sh setup_environment.sh +COPY ./docker/scripts/upgrade_environment.sh upgrade_environment.sh COPY ./docker/scripts/setup_agent.sh setup_agent.sh COPY ./docker/scripts/setup.sh setup.sh COPY ./docker/scripts/agent.sh agent.sh - -# Copy agent -WORKDIR $KATALON_AGENT_DIR -COPY --from=build /katalon/bin/cli-linux-x64 *.sh ./ - -# Setup -WORKDIR $KATALON_SCRIPT_DIR -RUN chmod -R 777 ./ RUN ./setup.sh -# PATH Environment -ENV PATH "$PATH:$KATALON_SCRIPT_DIR:$KATALON_AGENT_DIR:$GRADLE_BIN" -RUN echo "PATH=\"$PATH\"" > /etc/environment - -WORKDIR / COPY ./docker/entrypoint.sh /usr/local/bin/entrypoint.sh RUN ["chmod", "+x", "/usr/local/bin/entrypoint.sh"] ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 761c87de..ea2f7da8 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -4,6 +4,9 @@ set -xe echo "Entrypoint" +if [ "$AUTO_UPGRADE_ENVIRONMENT" = true ]; then + /katalon/scripts/upgrade_environment.sh || true +fi if [ -z "$KATALON_USER_ID" ]; then exec "$@" else diff --git a/docker/scripts/agent.sh b/docker/scripts/agent.sh index 4706b69a..82593865 100755 --- a/docker/scripts/agent.sh +++ b/docker/scripts/agent.sh @@ -23,7 +23,7 @@ cd $KATALON_AGENT_DIR --no-keep-files "$NO_KEEP_FILES" args=("./cli-linux-x64" "$@") -xvfb-run -s "-screen 0 $DISPLAY_CONFIGURATION" "${args[@]}" +xvfb-run -e /dev/stdout -s "-screen 0 $DISPLAY_CONFIGURATION" -a "${args[@]}" ret_code=$? exit $ret_code diff --git a/docker/scripts/setup.sh b/docker/scripts/setup.sh index e4bbe0dc..c9d3c24f 100755 --- a/docker/scripts/setup.sh +++ b/docker/scripts/setup.sh @@ -2,5 +2,5 @@ set -xe -./setup_environment.sh +# ./setup_environment.sh ./setup_agent.sh \ No newline at end of file diff --git a/docker/scripts/upgrade_environment.sh b/docker/scripts/upgrade_environment.sh new file mode 100755 index 00000000..d88f461b --- /dev/null +++ b/docker/scripts/upgrade_environment.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -xe + +echo "Upgrade Google Chrome" +chrome_package='google-chrome-stable_current_amd64.deb' +wget -O $chrome_package https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb +dpkg -i $chrome_package || apt -y -f install +rm $chrome_package +echo "$(google-chrome --version)" >> $KATALON_VERSION_FILE || true \ No newline at end of file diff --git a/package.json b/package.json index 2f4aa57c..05141d62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "katalon-agent", - "version": "v1.7.6", + "version": "v1.7.7", "description": "", "main": "cli.js", "scripts": {