diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9762dda2ee..d7300f7497 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,24 +1,129 @@ -# -# This is the GitLab CI configuration file for the mainstream QEMU -# project: https://gitlab.com/qemu-project/qemu/-/pipelines -# -# !!! DO NOT ADD ANY NEW CONFIGURATION TO THIS FILE !!! -# -# Only documentation or comments is accepted. -# -# To use a different set of jobs than the mainstream QEMU project, -# you need to set the location of your custom yml file at "custom CI/CD -# configuration path", on your GitLab CI namespace: -# https://docs.gitlab.com/ee/ci/pipelines/settings.html#custom-cicd-configuration-path -# -# ---------------------------------------------------------------------- -# -# QEMU CI jobs are based on templates. Some templates provide -# user-configurable options, modifiable via configuration variables. -# -# See https://qemu-project.gitlab.io/qemu/devel/ci.html#custom-ci-cd-variables -# for more information. -# +stages: + - generate_version + - build + - deploy -include: - - local: '/.gitlab-ci.d/qemu-project.yml' +generate_version: + stage: generate_version + image: alpine + tags: + - build + - amd64 + variables: + GIT_SUBMODULE_STRATEGY: none + artifacts: + reports: + dotenv: version.env + script: + - VERSION=${CI_COMMIT_TAG:-""} + - VERSION=${VERSION//"-"/"_"} # replace dashes with underscores in the version + - VERSION=${VERSION:-g${CI_COMMIT_SHORT_SHA}} + - echo "VERSION=$VERSION" > version.env + + - cat version.env + +.build_linux_template: + stage: build + image: $CI_DOCKER_REGISTRY/qemu-build:7 + tags: + - build + - amd64 + variables: + # Don't use parallel:matrix here, + # becuase needs:project doesn't support it + # https://docs.gitlab.com/ee/ci/yaml/#needsproject + PLATFORM: x86_64-linux-gnu + TARGET: "" # to be set in the job + artifacts: + paths: + - dist/qemu-*.tar.xz + - dist/archive_name_* + expire_in: 1 week + script: + - ./.github/workflows/scripts/configure-native.sh + - ninja -C build install + + - find ./install/qemu/share/qemu -maxdepth 1 -mindepth 1 -not -name 'esp*.bin' -exec rm -rfv {} \; + - DIST_DIR=${PWD}/dist + - mkdir -p ${DIST_DIR} + - cd ./install + - export ARCHIVE_NAME=qemu-${TARGET}-${VERSION}-${PLATFORM}.tar.xz + - tar cJvf ${DIST_DIR}/${ARCHIVE_NAME} qemu + - echo $ARCHIVE_NAME >${DIST_DIR}/archive_name_${TARGET}_${PLATFORM} + +# these build jobs names are used in needs:project in idf/qemu-tests +# don't rename it without updating the needs:project in idf/qemu-tests + +build_linux_xtensa_softmmu: + extends: .build_linux_template + variables: + TARGET: xtensa-softmmu + +build_linux_riscv32_softmmu: + extends: .build_linux_template + variables: + TARGET: riscv32-softmmu + +build_linux_riscv32_user: + extends: .build_linux_template + variables: + TARGET: riscv32-linux-user + +upload_to_http: + image: espressif/scp + stage: deploy + tags: + - deploy + - shiny + when: manual + allow_failure: true + variables: + # don't use "GIT_STRATEGY: none", because we need cleaning old artifacts in 'dist/' that came from previous pipelines + SSH_KEY: "$HTTP_UPLOAD_KEY" # used inside 'espressif/scp' + script: + # List of archives in dist/ + - DIST_FILE_LIST=$(find dist -name archive_name_\* -exec cat {} \+ | xargs -n1 | sort -u | xargs) + - cd dist + # Create a checksum file + - export RELEASE_CHECKSUM_FILE="qemu-${VERSION}-checksum.sha256" + - | + for n in $DIST_FILE_LIST; do + sz=$(stat -c%s "${n}"); + printf "# %s: %s bytes\n" "${n}" "${sz}" >> ${RELEASE_CHECKSUM_FILE}; + sha256sum -b "${n}" >> ${RELEASE_CHECKSUM_FILE}; + done + - DIST_FILE_LIST="${DIST_FILE_LIST} ${RELEASE_CHECKSUM_FILE}" + - scp ${DIST_FILE_LIST} ${HTTP_UPLOAD_DIR} + # Show info + - /bin/ls -l ${DIST_FILE_LIST} + - sha256sum ${DIST_FILE_LIST} + - cat "${RELEASE_CHECKSUM_FILE}" + - echo -e "\nArchives were published there:\n\n$(for n in ${DIST_FILE_LIST}; do echo "${HTTP_PUBLIC_DIR}/${n}"; done)\n" + +.update_idf_tools: + allow_failure: true + variables: + TOOL_NAME: "qemu" + TOOL_MEMBERS: "qemu-riscv32 qemu-xtensa" + TOOL_VERSION: ${VERSION} + trigger: + project: idf/idf-tools-updater + strategy: depend + +internal_update_idf_tools: + extends: .update_idf_tools + stage: deploy + needs: [ generate_version, upload_to_http ] + when: manual + variables: + TOOL_SHA256_URL: ${HTTP_PUBLIC_DIR}/qemu-${VERSION}-checksum.sha256 + +github_update_idf_tools: + extends: .update_idf_tools + stage: deploy + needs: [ generate_version ] + rules: + - if: $CI_COMMIT_TAG + when: manual + variables: + TOOL_SHA256_URL: ${GH_REPO_URL}/releases/download/${CI_COMMIT_TAG}/qemu-${VERSION}-checksum.sha256