-
Notifications
You must be signed in to change notification settings - Fork 16
111 lines (109 loc) · 4.33 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# (C) Copyright IBM 2023.
#
# This code is part of Qiskit.
#
# This code is licensed under the Apache License, Version 2.0 with LLVM
# Exceptions. You may obtain a copy of this license in the LICENSE.txt
# file in the root directory of this source tree.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
name: Continuous Integration
on: [push, pull_request]
jobs:
Build:
runs-on: ubuntu-latest
env:
CONAN_USER_HOME: ${{ github.workspace }}
steps:
- name: free-up-space
run: |
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
df -h
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10.9'
- name: Install pip packages
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Static checks
id: static_checks
if: github.event_name == 'pull_request'
run: pre-commit run --all-files --show-diff-on-failure
- name: Validate releasenotes
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'no-reno')
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: ./.github/renos_updated.ch
- name: Export QSSC_VERSION from Git version tag
run: |
version=`python -c "from setuptools_scm import get_version; print(get_version())"`
echo "QSSC_VERSION=$version" >> $GITHUB_ENV
- name: Try load Conan cache
id: cache
uses: actions/cache/restore@v3
with:
path: .conan
key: conan-${{ runner.os }}-${{ hashFiles('conandata.yml', 'conanfile.py', 'conan/**/*.py', 'conan/**/*.yml') }}
restore-keys: conan-${{ runner.os }}
- name : Print cache hit/miss
run: |
echo "Cache was hit: ${{ steps.cache.outputs.cache-hit }}"
# If we have a cache miss on 'main', clear the cache.
# A dependency was updated, so we need to drop the old one
# to prevent unbounded cache growth over time.
- name : Clear Conan cache
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.cache.outputs.cache-hit != 'true'
run: |
rm -rf ./.conan
- name: Create Conan default profile
run: |
conan profile new default --detect || true
conan profile update settings.compiler.libcxx=libstdc++11 default
- name: Add QASM, LLVM, and clang tools recipes to Conan cache.
run: ./conan_deps.sh
- name: Create build dir
run: mkdir build
- name: Conan install
id: conan_install
working-directory: build
run: |
export CONAN_LLVM_GIT_CACHE="${{ runner.temp }}/llvm-project"
conan install .. --build=outdated -pr:h default -pr:b default
- name: Build
id: build
working-directory: build
run: |
conan build ..
- name: Test
id: test
working-directory: build
run: conan build .. --test
# On 'pull_request' run Clang tidy
# Run last as clang tidy takes significantly longer
# than building.
- name: Clang tidy
uses: ZedThree/[email protected]
id: clang_tidy
if: github.event_name == 'pull_request'
with:
config_file: '.clang-tidy'
build_dir: build
# On 'main' branch, always save the cache if Conan install succeeded.
# Note: we only update the cache from 'main' to avoid "cache thrashing", which would result in the 'main'
# cache getting LRU-evicted for every PR, since a single run uses most of the 10GB repo limit.
- uses: actions/cache/save@v3
if: always() && (github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.conan_install.outcome == 'success' && steps.cache.outputs.cache-hit != 'true')
with:
path: .conan
key: conan-${{ runner.os }}-${{ hashFiles('conandata.yml', 'conanfile.py', 'conan/**/*.py', 'conan/**/*.yml') }}