Skip to content
Merged
9 changes: 9 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -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"
92 changes: 92 additions & 0 deletions .github/workflows/trigger-gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
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:-<not found>}"
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: ${{ vars.GITLAB_PROJECT_PATH }}

- name: Trigger pipeline on mirrored branch
id: trigger
run: |
OUTPUT=$(glab ci run --branch "${{ github.head_ref }}" --repo "$GITLAB_PROJECT_PATH")
echo "$OUTPUT"
PIPELINE_ID=$(echo "$OUTPUT" | sed 's/.*id: \([0-9]*\).*/\1/')
echo "pipeline_id=${PIPELINE_ID}" >> "$GITHUB_OUTPUT"
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITLAB_HOST: gitlab.com
GITLAB_PROJECT_PATH: ${{ vars.GITLAB_PROJECT_PATH }}

- name: Monitor GitLab pipeline
run: |
PIPELINE_ID="${{ steps.trigger.outputs.pipeline_id }}"
ENCODED_PATH="${GITLAB_PROJECT_PATH//\//%2F}"
TIMEOUT=300
ELAPSED=0
POLL_INTERVAL=15

echo "Monitoring pipeline ${PIPELINE_ID}..."
while true; do
RESPONSE=$(glab api "projects/${ENCODED_PATH}/pipelines/${PIPELINE_ID}" 2>/dev/null)
STATUS=$(echo "$RESPONSE" | jq -r '.status // empty')
PIPELINE_URL=$(echo "$RESPONSE" | jq -r '.web_url // empty')
echo " elapsed=${ELAPSED}s status=${STATUS:-<unknown>}"
case "$STATUS" in
success)
echo "Pipeline succeeded."
exit 0
;;
failed|canceled|skipped)
echo "Pipeline ended with status: ${STATUS}. ${PIPELINE_URL}"
exit 1
;;
esac
if [ "$ELAPSED" -ge "$TIMEOUT" ]; then
echo "Timed out after ${TIMEOUT}s waiting for pipeline to complete."
exit 1
fi
sleep "$POLL_INTERVAL"
ELAPSED=$((ELAPSED + POLL_INTERVAL))
done
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITLAB_HOST: gitlab.com
GITLAB_PROJECT_PATH: ${{ vars.GITLAB_PROJECT_PATH }}
48 changes: 48 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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"
- if: $CI_PIPELINE_SOURCE == "api"
- if: $CI_PIPELINE_SOURCE == "external"
- if: $CI_PIPELINE_SOURCE == "external_pull_request_event"

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"
# Automatically run when triggered from GitHub, automatically via sync or via the API
- if: $CI_PIPELINE_SOURCE == "api"
- if: $CI_PIPELINE_SOURCE == "external_pull_request_event"
# Manually run from any other branch
- when: manual
before_script:
- !reference [.cargo_publish_crate, before_script]
script:
- |
if [ "$CI_COMMIT_BRANCH" != "rigetti-main" ]; then
sed -i "s/^version = \"\([^\"]*\)\"/version = \"\1-${CI_COMMIT_SHORT_SHA}\"/" tracing-error/Cargo.toml
echo "Patched version: $(grep '^version' tracing-error/Cargo.toml)"
dirty="--allow-dirty"
else
dirty=""
fi
- cargo publish $dirty -p tracing-error --registry rigetti-cargo
11 changes: 2 additions & 9 deletions tracing-error/src/backtrace.rs
Comment thread
BatmanAoD marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,7 @@ impl fmt::Display for SpanTrace {
try_bool!(write!(f, "\n with {}", fields), err);
}

if let Some((file, line)) = metadata
.file()
.and_then(|file| metadata.line().map(|line| (file, line)))
{
if let Some((file, line)) = metadata.file().zip(metadata.line()) {
try_bool!(write!(f, "\n at {}:{}", file, line), err);
}

Expand Down Expand Up @@ -240,11 +237,7 @@ impl fmt::Debug for SpanTrace {
write!(f, ", fields: {:?}", self.fields)?;
}

if let Some((file, line)) = self
.metadata
.file()
.and_then(|file| self.metadata.line().map(|line| (file, line)))
{
if let Some((file, line)) = self.metadata.file().zip(self.metadata.line()) {
write!(f, ", file: {:?}, line: {:?}", file, line)?;
}

Expand Down
Loading