diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000000..1a3e354f93 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,9 @@ +[registries.rigetti-cargo] +index = "sparse+https://rigetti-733799784722.d.codeartifact.us-west-2.amazonaws.com/cargo/rigetti-cargo/" +# Unlike internal repos, this does not include the `--profile` argument, which is not used by CI. +# This makes it less convenient to use locally, but it should only be used for *publishing*, +# never for donwloading dependencies. +credential-provider = ["cargo:token-from-stdout", "sh", "-c", "aws codeartifact get-authorization-token --domain rigetti --domain-owner 733799784722 --region us-west-2 --query authorizationToken --output text"] + +[registry] +default = "crates-io" diff --git a/.github/workflows/trigger-gitlab-ci.yml b/.github/workflows/trigger-gitlab-ci.yml new file mode 100644 index 0000000000..51d014d7b7 --- /dev/null +++ b/.github/workflows/trigger-gitlab-ci.yml @@ -0,0 +1,51 @@ +name: Trigger GitLab CI + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + trigger: + name: Trigger GitLab pipeline + runs-on: ubuntu-latest + container: gitlab/glab + steps: + - name: Sync mirror and wait for branch SHA + run: | + BRANCH="${{ github.head_ref }}" + EXPECTED_SHA="${{ github.event.pull_request.head.sha }}" + ENCODED_PATH="${GITLAB_PROJECT_PATH//\//%2F}" + TIMEOUT=300 + ELAPSED=0 + + echo "Triggering mirror sync..." + glab api --method POST "projects/${ENCODED_PATH}/mirror/pull" + echo "" + + echo "Waiting for GitLab branch '${BRANCH}' to reach SHA ${EXPECTED_SHA}..." + while true; do + ACTUAL_SHA=$(glab api "projects/${ENCODED_PATH}/repository/branches/${BRANCH}" 2>/dev/null \ + | jq -r '.commit.id // empty') + echo " elapsed=${ELAPSED}s actual_sha=${ACTUAL_SHA:-}" + if [ "$ACTUAL_SHA" = "$EXPECTED_SHA" ]; then + echo "SHA matched." + break + fi + if [ "$ELAPSED" -ge "$TIMEOUT" ]; then + echo "Timed out after ${TIMEOUT}s waiting for mirror to sync." + exit 1 + fi + sleep 10 + ELAPSED=$((ELAPSED + 10)) + done + env: + GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} + GITLAB_HOST: gitlab.com + GITLAB_PROJECT_PATH: ${{ secrets.GITLAB_PROJECT_PATH }} + + - name: Trigger pipeline on mirrored branch + run: glab ci run --branch "${{ github.head_ref }}" --repo "$GITLAB_PROJECT_PATH" + env: + GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} + GITLAB_HOST: gitlab.com + GITLAB_PROJECT_PATH: ${{ secrets.GITLAB_PROJECT_PATH }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000..79b757647b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,34 @@ +include: + - project: "rigetti/qcs/utilities/qcs-infrastructure" + ref: v0.1.1 + file: + - gitlab-ci/common.yaml + - gitlab-ci/gitlab.yaml + - gitlab-ci/rust.yaml + +workflow: + rules: + - if: $CI_COMMIT_BRANCH == "rigetti-main" + - if: $CI_PIPELINE_SOURCE == "trigger" + - if: $CI_PIPELINE_SOURCE == "web" + +default: + !reference [.standard_defaults] + +variables: + QCS_INFRASTRUCTURE_REF: v0.1.1 + RUST_CI_IMAGE_TAG: $QCS_INFRASTRUCTURE_REF + CLI_TOOLS_IMAGE_TAG: $QCS_INFRASTRUCTURE_REF + +publish-tracing-error: + extends: [.cargo_publish_crate] + needs: [] + rules: + # Automatically run from rigetti-main + - if: $CI_COMMIT_BRANCH == "rigetti-main" + # Manually run from any other branch + - when: manual + before_script: + - !reference [.cargo_publish_crate, before_script] + script: + - cargo publish -p tracing-error --registry rigetti-cargo