Skip to content

Commit

Permalink
fixup! CI: Add cheshire CI
Browse files Browse the repository at this point in the history
      run: |
        while [curl -L \
              -H "Accept: application/vnd.github+json" \
              -H "Authorization: Bearer ${{ secrets.CHESHIRE_TOKEN }}" \
              -H "X-GitHub-Api-Version: 2022-11-28" \
              https://api.github.com/repos/pulp-platform/cheshire/commits/cva6-ci/$(git rev-parse --short "$GITHUB_SHA")/check-runs \
              | grep "\"status\": \"in_progress\""]
        do; sleep 10s; end

Signed-off-by: Nils Wistoff <[email protected]>
  • Loading branch information
niwis committed Feb 20, 2024
1 parent de90bdf commit 0d92304
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 10 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/cheshire.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@
# SPDX-License-Identifier: Apache-2.0

name: cheshire
on: [push, pull_request]
on: [push, pull_request_target]

jobs:
init:
name: init
trigger_cheshire_ci:
name: Trigger Cheshire CI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout Cheshire
uses: actions/checkout@v4
with:
repository: pulp-platform/cheshire
path: cheshire
ref: cva6/pulp-v1.0.0
run-cheshire-ci:
name: run-cheshire-ci
needs: init-cheshire
uses: pulp-platform/cheshire/.github/workflows/lint.yml@cva6/pulp-v1.0.0
token: ${{ secrets.CHESHIRE_TOKEN }}
- name: Patch Bender.lock
run: "sed -i \"/ cva6:/{n;s/.*/ revision: $GITHUB_SHA/;}\" Bender.lock"
- name: Commit ref
run: |
git checkout -b cva6-ci/$(git rev-parse --short "$GITHUB_SHA")
git add Bender.lock
git -c user.name='CVA6 CI Bot' -c user.email='[email protected]' commit -m "CVA6 regression test"
- name: Push ref
run: git push --set-upstream origin cva6-ci/$(git rev-parse --short "$GITHUB_SHA")
- name: Wait for Cheshire CI
run: |
.github/workflows/github-ci.py ${{ secrets.CHESHIRE_TOKEN }} pulp-platform cheshire cva6-ci/$(git rev-parse --short "$GITHUB_SHA") 2022-11-28 720 10
46 changes: 46 additions & 0 deletions .github/workflows/github-ci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3
#
# Copyright 2022 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Paul Scheffler <[email protected]>
# Nils Wistoff <[email protected]>

import os
import sys
import time
import requests
import urllib.parse


def main(token: str, org: str, repo: str, ref: str, api_version: str, poll_count: int, poll_period: int):
# Derive pipeline URL
check_runs = f'https://api.github.com/repos/{org}/{repo}/commits/{ref}/check-runs'
headers={'Accept': 'application/vnd.github+json',
'Authorization': f'Bearer {token}',
'X-GitHub-Api-Version': api_version}

# Wait for pipeline to complete
for i in range(1, poll_count+1):
pending = 0
failed = 0
response = requests.get(pipelines, headers=headers).json()
for r in response["check_runs"]:
if r['status'] == 'in_progress':
pending+=1
if r['conclusion'] == 'failure':
failed+=1
if failed:
print(f'[{i*poll_period}s] Pipeline failure!')
return 1
if not pending:
print(f'[{i*poll_period}s] Pipeline success!')
return 0
else:
print(f'[{poll_count*poll_period}s] Pipeline completion timeout!')
return 3


if __name__ == '__main__':
sys.exit(main(*(int(a) if a.isdigit() else a for a in sys.argv[1:])))

0 comments on commit 0d92304

Please sign in to comment.