Skip to content

chore(ci): support for nightly builds in actions #5

chore(ci): support for nightly builds in actions

chore(ci): support for nightly builds in actions #5

Workflow file for this run

name: Nightly Build
#on:
# workflow_dispatch:
# schedule:
# - cron: '0 20 * * *'
on:
pull_request:
types: [opened, reopened, synchronize]
env:
HELM_NAME: automq-for-rocketmq
DOCKER_REPO: automqinc/automq-for-rocketmq
DOCKER_NIGHTLY_VERSION: nightly
JOB_INDEX: 1
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
version-json: ${{ steps.build_images.outputs.nightly-version }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install flatc
run: sudo bash install_flatc.sh
- uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
cache: "maven"
- name: Build with Maven
run: |
mvn -Prelease-all clean install -U
- name: docker-login
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and save docker images
id: build_images
working-directory: ./distribution/docker
env:
DOCKER_REPO: ${{ env.DOCKER_REPO }}
DOCKER_NIGHTLY_VERSION: ${{ env.DOCKER_NIGHTLY_VERSION }}
run: |
FULL_NODE_VERSION=$(git ls-remote --tags | awk -F '/' 'END{print $3}')
COMMIT_VERSION=$(git rev-parse --short HEAD)
VERSION=${FULL_NODE_VERSION}-${COMMIT_VERSION}-${DOCKER_NIGHTLY_VERSION}
sh build-ci.sh ${DOCKER_REPO} ${VERSION}
docker push ${DOCKER_REPO}:${VERSION}
echo "nightly-version=$VERSION" >> $GITHUB_OUTPUT
deploy:
name: Deploy AutoMQ for RocketMQ
needs: [build]
runs-on: private-k3s
timeout-minutes: 60
outputs:
namespace: ${{ steps.create_namespace.outputs.namespace }}
strategy:
matrix:
version: ${{ fromJSON(needs.build.outputs.version-json) }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
- name: Get kubeconfig
env:
KUBECONFIG_FILE: '${{ secrets.KUBE_CONFIG }}'
run: |
mkdir -p ~/.kube
echo $KUBECONFIG_FILE | base64 -d > ~/.kube/config
- name: Create Namespace
id: create_namespace
env:
JOB_INDEX: ${{ env.JOB_INDEX }}
run: |
REPO_NAME=`echo ${GITHUB_REPOSITORY#*/} | sed -e "s/\//-/g" | cut -c1-36 | tr '[A-Z]' '[a-z]'`
NAMESPACE=${REPO_NAME}-${GITHUB_RUN_ID}-${JOB_INDEX}
kubectl create namespace $NAMESPACE
echo "namespace=$NAMESPACE" >> $GITHUB_OUTPUT
- name: Deploy RocketMQ
working-directory: distribution/helm
env:
NAMESPACE: ${{ steps.create_namespace.outputs.namespace }}
DOCKER_REPO: ${{ env.DOCKER_REPO }}
run: |
sh deploy-ci.sh ${DOCKER_REPO} ${{ matrix.version }} ${NAMESPACE}
run_e2e_grpc_java:
name: Run e2e test for grpc java
needs: [ build, deploy ]
runs-on: private-k3s
strategy:
matrix:
version: ${{ fromJSON(needs.build.outputs.version-json) }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install flatc
run: sudo bash install_flatc.sh
- name: Build rocketmq dependency
run: |
mvn clean install -U -Dmaven.test.skip=true
- uses: actions/checkout@v3
if: always()
with:
repository: AutoMQ/rocketmq-e2e
ref: master
path: rocketmq-e2e
token: ${{ secrets.PAT_E2E }}
- name: e2e test
env:
HELM_NAME: ${{ env.HELM_NAME }}
NAMESPACE: ${{ needs.deploy.outputs.namespace }}
run: |
cd rocketmq-e2e
cd java/e2e && mvn -B test -DnamesrvAddr=${HELM_NAME}-broker.${NAMESPACE}.svc.pve1.local:8081 -DendPoint=${HELM_NAME}-broker.${NAMESPACE}.svc.pve1.local:8081
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: '**/surefire-reports/TEST-*.xml'
annotate_only: true
include_passed: true
detailed_summary: true
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: test-e2e-grpc-java-log.txt
path: testlog.txt
run_e2e_remoting_java:
name: Run e2e test for remoting java
needs: [ build, deploy ]
runs-on: private-k3s
strategy:
matrix:
version: ${{ fromJSON(needs.build.outputs.version-json) }}
steps:
- name: Delay
env:
DELAY_SECONDS: 30
run: |
sleep $DELAY_SECONDS
- uses: actions/checkout@v3
with:
submodules: true
- name: Install flatc
run: sudo bash install_flatc.sh
- name: Build rocketmq dependency
run: |
mvn clean install -U -Dmaven.test.skip=true
- uses: actions/checkout@v3
if: always()
with:
repository: AutoMQ/rocketmq-e2e
ref: master
path: rocketmq-e2e
token: ${{ secrets.PAT_E2E }}
- name: e2e test
env:
HELM_NAME: ${{ env.HELM_NAME }}
NAMESPACE: ${{ needs.deploy.outputs.namespace }}
run: |
cd rocketmq-e2e
cd java/e2e-v4 && mvn -B test -DnamesrvAddr=${HELM_NAME}-broker.${NAMESPACE}.svc.pve1.local:8081
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: '**/surefire-reports/TEST-*.xml'
annotate_only: true
include_passed: true
detailed_summary: true
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: test-e2e-remoting-java-log.txt
path: testlog.txt
clean:
name: Clean
needs: [deploy, run_e2e_grpc_java, run_e2e_remoting_java]
runs-on: private-k3s
timeout-minutes: 60
strategy:
matrix:
version: ${{ fromJSON(needs.list-version.outputs.version-json) }}
steps:
- name: clean Rocketmq
working-directory: distribution/helm
env:
NAMESPACE: ${{ needs.deploy.outputs.namespace }}
DOCKER_REPO: ${{ env.DOCKER_REPO }}
run: |
sh clean-ci.sh ${NAMESPACE}