Closed vipulgupta2048 closed 1 month ago
name: If Levaithan was reusuable? on: workflow_call: inputs: LEVIATHAN_REF: # id of input description: "Leviathan branch, or tag, or commit to test with. Examples: 'refs/heads/<branchName>', 'refs/tags/<tagName>', '<commitId>'" required: false type: string default: 'refs/heads/master' # CONFIG: # description: 'path to config.js' # required: false # default: './suites/config.js' SUITES: description: 'path to test folders' required: false type: string default: './suites' # TEST_SUITE_NAME: # description: 'which test suite to run' # required: false # type: string WORKSPACE: description: 'path to WORKSPACE' required: false type: string default: './.leviathan-inputs' DEVICE_TYPE: description: "slug of device type" required: true type: string REPORTS: description: "path to reports directory" required: false type: string default: "./reports" ENVIRONMENT: description: "What BalenaCloud env, balena-cloud or balena-machine" required: true type: string default: "balena-cloud" BALENACLOUD_ORG: required: false description: "Organization used during cloud suite to create fleets, etc." default: "testbot" type: string BALENACLOUD_APP_NAME: description: "Testbot fleet for finding available Leviathan workers. Not used for QEMU workers. Can accept a list of apps separated by commas." type: string required: false default: "balena/testbot-rig" BALENACLOUD_API_URL: type: string required: false default: "balena-cloud.com" BALENAMACHINE_API_URL: required: false type: string default: "bm.balena-dev.com" BALENACLOUD_SSH_URL: required: false type: string default: "ssh.devices.bm.balena-dev.com" BALENACLOUD_SSH_PORT: default: 222 type: number required: false QEMU_CPUS: required: false type: number default: 4 QEMU_MEMORY: type: string required: false default: "1G" WORKER_TYPE: description: "Valid choices: testbot/qemu" type: string required: true LEVIATHAN_DEBUG: description: | Use this parameter to modify the default debugging settings on test runs. To debug test runs when rebuilding, add new values to this parameter separated with commas. Know more about the possible values available for debugging: https://balena-os.github.io/leviathan/pages/Getting-Started/debugging.html Example value: dev: true, failFast: false type: string required: false secrets: BALENACLOUD_API_KEY: required: false BALENAMACHINE_API_KEY: required: false jobs: build: runs-on: ubuntu-22.04 steps: - name: Get Leviathan checked out uses: actions/checkout@v4 with: repository: balena-os/leviathan submodules: true # path: ./leviathan-workspace # The branch, tag or SHA to checkout. When checking out the repository that # triggered a workflow, this defaults to the reference or SHA for that event. # Otherwise, uses the default branch. ref: ${{ inputs.LEVIATHAN_REF }} # - name: Set up Docker Buildx # uses: docker/setup-buildx-action@v3 # Don't think, I need this since docker-compose uses only buildkit which we enabled by default in Makefile - name: Build it, and they might come shell: bash env: WORKER_TYPE: ${{ inputs.WORKER_TYPE }} # SECUREBOOT: ${{ inputs.SECUREBOOT }} run: | make config make build docker image ls -a - name: Save the images shell: bash run: | docker save --output /tmp/corelatest.tar leviathan_core:latest docker save --output /tmp/clientlatest.tar leviathan_client:latest - name: Upload Core artifact uses: actions/upload-artifact@v3 with: name: corelatest.tar path: /tmp/corelatest.tar compression-level: 7 - name: Upload Client artifact uses: actions/upload-artifact@v3 with: name: clientlatest.tar path: /tmp/clientlatest.tar compression-level: 7 test: runs-on: ubuntu-22.04 needs: build steps: - name: Download artifact uses: actions/download-artifact@v3 with: name: clientlatest.tar path: /tmp - name: Download artifact uses: actions/download-artifact@v3 with: name: corelatest.tar path: /tmp - name: Load image shell: bash run: | docker image ls -a docker load --input /tmp/corelatest.tar docker load --input /tmp/clientlatest.tar docker image ls -a - name: Fetching code to be tested uses: actions/checkout@v4 with: submodules: true - name: Get Leviathan checked out uses: actions/checkout@v4 with: repository: balena-os/leviathan submodules: true path: ./leviathan # The branch, tag or SHA to checkout. When checking out the repository that # triggered a workflow, this defaults to the reference or SHA for that event. # Otherwise, uses the default branch. ref: ${{ inputs.LEVIATHAN_REF }} # - name: Fetching the Private Contracts # uses: actions/checkout@v4 # with: # repository: balena-io/private-contracts # path: './leviathan/core/private-contracts' - name: All the copying stage shell: bash working-directory: ./leviathan run: | mkdir -p ${{ inputs.WORKSPACE }} (cd ${{ inputs.WORKSPACE }} && mkdir -p ${{ inputs.REPORTS }}) cp ../${{ inputs.SUITES }}/config.js ${{ inputs.WORKSPACE }} cp -r ../${{ inputs.SUITES }} . # - name: Show the final config.js before RUN # working-directory: ./leviathan-workspace # run: | # cat ${{ inputs.WORKSPACE }}/config.js # shell: bash - name: generate a unique subnet for this job working-directory: ./leviathan run: | make subnet || true make config shell: bash - name: Test working-directory: ./leviathan shell: bash env: BALENACLOUD_API_KEY: ${{ secrets.BALENACLOUD_API_KEY }} BALENAMACHINE_API_KEY: ${{ secrets.BALENAMACHINE_API_KEY }} BALENACLOUD_API_URL: ${{ inputs.BALENACLOUD_API_URL }} BALENACLOUD_APP_NAME: ${{ inputs.BALENACLOUD_APP_NAME }} BALENACLOUD_ORG: ${{ inputs.BALENACLOUD_ORG }} BALENACLOUD_SSH_PORT: ${{ inputs.BALENACLOUD_SSH_PORT }} BALENACLOUD_SSH_URL: ${{ inputs.BALENACLOUD_SSH_URL }} BALENAMACHINE_API_URL: ${{ inputs.BALENAMACHINE_API_URL }} DEVICE_TYPE: ${{ inputs.DEVICE_TYPE }} ENVIRONMENT: ${{ inputs.ENVIRONMENT }} QEMU_CPUS: ${{ inputs.QEMU_CPUS }} QEMU_MEMORY: ${{ inputs.QEMU_MEMORY }} REPORTS: ${{ inputs.REPORTS }} SUITES: ${{ inputs.SUITES }} # TEST_SUITE_NAME: ${{ inputs.TEST_SUITE_NAME }} WORKER_TYPE: ${{ inputs.WORKER_TYPE }} WORKSPACE: ${{ inputs.WORKSPACE }} run: | make test || exit 1 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4 with: name: reports-${{ env.WORKER_TYPE }}-${{ env.DEVICE_TYPE }} path: ${{ inputs.reports }} - name: Please tear down shell: bash working-directory: ./leviathan run: | make down