diff --git a/.github/workflows/build-using-buildscripts.yml b/.github/workflows/build-using-buildscripts.yml new file mode 100644 index 000000000..3de7ecd6d --- /dev/null +++ b/.github/workflows/build-using-buildscripts.yml @@ -0,0 +1,157 @@ +name: Build dependencies and CFEngine hub package + +on: + workflow_call: + inputs: + additional_artifacts: + description: "Additional files or directories to include in artifacts" + default: "" + required: false + type: string + + secrets: + GH_ACTIONS_SSH_DEPLOY_KEY_ENTERPRISE_REPO: + required: true + GH_ACTIONS_SSH_DEPLOY_KEY_NOVA_REPO: + required: true + GH_ACTIONS_SSH_DEPLOY_KEY_MISSION_PORTAL_REPO: + required: true + GH_ACTIONS_SSH_KEY_BUILD_ARTIFACTS_CACHE: + required: true + +permissions: + contents: read + +jobs: + build_cfengine_hub_package: + name: Build package + runs-on: ubuntu-22.04 + steps: + - name: Checkout Together Action + uses: actions/checkout@v3 + with: + repository: cfengine/together-javascript-action + ref: main + ssh-key: ${{ secrets.GH_ACTIONS_SSH_DEPLOY_KEY_TOGETHER_REPO }} + ssh-known-hosts: github.com + + - name: Action step + uses: ./ + id: together + with: + myToken: ${{ secrets.GITHUB_TOKEN }} + + - name: Checkout Core + uses: actions/checkout@v3 + with: + repository: cfengine/core + path: core + ref: ${{steps.together.outputs.core || github.base_ref}} + submodules: recursive + + - name: Checkout Masterfiles + uses: actions/checkout@v3 + with: + repository: cfengine/masterfiles + path: masterfiles + ref: ${{steps.together.outputs.masterfiles || github.base_ref}} + + - name: Checkout Buildscripts + uses: actions/checkout@v3 + with: + repository: cfengine/buildscripts + path: buildscripts + fetch-depth: 20 + + - name: Checkout Nova + uses: actions/checkout@v3 + with: + repository: cfengine/nova + path: nova + ref: ${{steps.together.outputs.nova || github.base_ref}} + ssh-key: ${{ secrets.GH_ACTIONS_SSH_DEPLOY_KEY_NOVA_REPO }} + ssh-known-hosts: github.com + + - name: Checkout Enterprise + uses: actions/checkout@v3 + with: + repository: cfengine/enterprise + path: enterprise + ref: ${{steps.together.outputs.enterprise || github.base_ref}} + submodules: recursive + ssh-key: ${{ secrets.GH_ACTIONS_SSH_DEPLOY_KEY_ENTERPRISE_REPO }} + ssh-known-hosts: github.com + + - name: Checkout Mission Portal + uses: actions/checkout@v3 + with: + repository: cfengine/mission-portal + path: mission-portal + ref: ${{steps.together.outputs.mission-portal || github.base_ref}} + submodules: recursive + ssh-key: ${{ secrets.GH_ACTIONS_SSH_DEPLOY_KEY_MISSION_PORTAL_REPO }} + ssh-known-hosts: github.com + + - name: get PACKAGE_SHA for package cache + run: echo "PACKAGE_SHA=$(buildscripts/ci/package-sha.sh)" | tee -a ${GITHUB_ENV} + + - name: get SHA of buildscripts/deps-packaging last commit + run: echo "DEPS_SHA=$(git log --pretty='format:%h' -1 -- .)" | tee -a ${GITHUB_ENV} + working-directory: buildscripts/deps-packaging + + - name: restore artifacts cache + uses: actions/cache/restore@v3 + with: + path: artifacts + key: artifacts-${{ env.PACKAGE_SHA }} + restore-keys: | + artifacts-${{ env.PACKAGE_SHA }} + + - name: Restore dependency cache + uses: actions/cache/restore@v3 + with: + path: cache + key: deps-${{ github.base_ref }}-${{ env.DEPS_SHA }} + restore-keys: | + deps-${{ github.base_ref }} + deps-master + deps + + - name: restore configured and built core and nova projects + uses: actions/cache/restore@v3 + with: + path: build + key: build-${{ env.PACKAGE_SHA }} + restore-keys: | + build-${{ env.PACKAGE_SHA }} + + - name: Build package in docker + env: + GH_ACTIONS_SSH_KEY_BUILD_ARTIFACTS_CACHE: ${{ secrets.GH_ACTIONS_SSH_KEY_BUILD_ARTIFACTS_CACHE }} + run: | + if [ ! -f artifacts/cfe*deb ]; then + buildscripts/ci/docker-build-package.sh ${{ inputs.additional_artifacts }} + fi + + - name: Save dependency cache + uses: actions/cache/save@v3 + with: + path: cache + key: deps-${{ github.base_ref }}-${{ env.DEPS_SHA }} + + - name: Save artifacts cache + uses: actions/cache/save@v3 + with: + path: | + artifacts + packages + key: artifacts-${{ env.PACKAGE_SHA }} + + - name: Save artifacts + if: success() || failure() + uses: actions/upload-artifact@v4 + with: + name: artifacts + path: | + artifacts + packages diff --git a/.github/workflows/deployment-tests.yml b/.github/workflows/deployment-tests.yml new file mode 100644 index 000000000..ed0868e15 --- /dev/null +++ b/.github/workflows/deployment-tests.yml @@ -0,0 +1,145 @@ +name: Deployment tests for built package + +on: + workflow_call: + secrets: + GH_ACTIONS_SSH_DEPLOY_KEY_ENTERPRISE_REPO: + required: true + GH_ACTIONS_SSH_DEPLOY_KEY_NOVA_REPO: + required: true + GH_ACTIONS_SSH_DEPLOY_KEY_MISSION_PORTAL_REPO: + required: true + GH_ACTIONS_SSH_KEY_BUILD_ARTIFACTS_CACHE: + required: true + +permissions: + contents: read + pull-requests: read + +jobs: + deployment_tests: + name: Run simple deployment tests + runs-on: ubuntu-22.04 + steps: + - name: Checkout Together Action + uses: actions/checkout@v3 + with: + repository: cfengine/together-javascript-action + ref: main + ssh-key: ${{ secrets.GH_ACTIONS_SSH_DEPLOY_KEY_TOGETHER_REPO }} + ssh-known-hosts: github.com + + - name: Action step + uses: ./ + id: together + with: + myToken: ${{ secrets.GITHUB_TOKEN }} + + - name: Checkout Core + uses: actions/checkout@v3 + with: + repository: cfengine/core + path: core + ref: ${{steps.together.outputs.core || github.base_ref}} + submodules: recursive + + - name: Checkout Masterfiles + uses: actions/checkout@v3 + with: + repository: cfengine/masterfiles + path: masterfiles + ref: ${{steps.together.outputs.masterfiles || github.base_ref}} + + - name: Checkout Buildscripts + uses: actions/checkout@v3 + with: + repository: cfengine/buildscripts + path: buildscripts + ref: ${{steps.together.outputs.buildscripts || github.base_ref}} + fetch-depth: 20 + + - name: Checkout Nova + uses: actions/checkout@v3 + with: + repository: cfengine/nova + path: nova + ref: ${{steps.together.outputs.nova || github.base_ref}} + ssh-key: ${{ secrets.GH_ACTIONS_SSH_DEPLOY_KEY_NOVA_REPO }} + ssh-known-hosts: github.com + + - name: Checkout Enterprise + uses: actions/checkout@v3 + with: + repository: cfengine/enterprise + path: enterprise + ref: ${{steps.together.outputs.enterprise || github.base_ref}} + submodules: recursive + ssh-key: ${{ secrets.GH_ACTIONS_SSH_DEPLOY_KEY_ENTERPRISE_REPO }} + ssh-known-hosts: github.com + + - name: Checkout Mission Portal + uses: actions/checkout@v3 + with: + repository: cfengine/mission-portal + path: mission-portal + ref: ${{steps.together.outputs.mission-portal || github.base_ref}} + submodules: recursive + ssh-key: ${{ secrets.GH_ACTIONS_SSH_DEPLOY_KEY_MISSION_PORTAL_REPO }} + ssh-known-hosts: github.com + + - name: get PACKAGE_SHA for package cache + run: echo "PACKAGE_SHA=$(buildscripts/ci/package-sha.sh)" | tee -a ${GITHUB_ENV} + + - name: get SHA of buildscripts/deps-packaging last commit + run: echo "DEPS_SHA=$(git log --pretty='format:%h' -1 -- .)" | tee -a ${GITHUB_ENV} + working-directory: buildscripts/deps-packaging + + - name: restore artifacts cache + uses: actions/cache/restore@v3 + with: + path: artifacts + key: artifacts-${{ env.PACKAGE_SHA }} + restore-keys: | + artifacts-${{ env.PACKAGE_SHA }} + + - name: Restore dependency cache + uses: actions/cache/restore@v3 + with: + path: cache + key: deps-${{ github.base_ref }}-${{ env.DEPS_SHA }} + restore-keys: | + deps-${{ github.base_ref }} + deps-master + deps + + - name: Build package in docker + id: build_package + env: + GH_ACTIONS_SSH_KEY_BUILD_ARTIFACTS_CACHE: ${{ secrets.GH_ACTIONS_SSH_KEY_BUILD_ARTIFACTS_CACHE }} + run: | + if [ ! -f artifacts/cfe*deb ]; then + buildscripts/ci/docker-build-package.sh + fi + + - name: Run deployment tests + run: buildscripts/ci/docker-deployment-tests.sh + + - name: Save dependency cache + uses: actions/cache/save@v3 + with: + path: cache + key: deps-${{ github.base_ref }}-${{ env.DEPS_SHA }} + + - name: Save artifacts cache + uses: actions/cache/save@v3 + with: + path: artifacts + key: artifacts-${{ env.PACKAGE_SHA }} + + - name: Save artifacts + if: success() || failure() + uses: actions/upload-artifact@v4 + with: + name: deployment-test-artifacts + path: | + artifacts