summaryrefslogtreecommitdiff
path: root/.circleci/config.yml
blob: 78ae63b2de659fcfd60237df9c722d774ff8931a (plain)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Scala CircleCI 2.1 configuration file
#
# Check https://circleci.com/docs/2.0/sample-config/ for more details
#

version: 2.1

executors:
  chisel-executor:
    # Use the chisel3-tools image to build and run FIRRTL and chisel tests.
    docker:
      - image: ucbbar/chisel3-tools
        user: "chisel"

    working_directory: ~/repo

    environment:
      # Customize the JVM maximum heap limit
      JVM_OPTS: -Xmx3200m
      TERM: dumb
      CHISEL_REV: origin/master
      FIRRTL_REPO: git@github.com:freechipsproject/firrtl.git
      FIRRTL_BRANCH: master
      FIRRTL_REV: master
      TREADLE_REPO: git@github.com:freechipsproject/treadle.git
      TREADLE_BRANCH: master
      TREADLE_REV: master
      CHECKSTYLE_LIMIT: 40
      SBT_ARGS: ""

commands:
  test-chisel:
    description: "Run chisel tests with a specific Scala version"
    parameters:
      scalaVersion:
        type: string
        default: ""
    steps:
      - attach_workspace:
          at: /home/chisel

      # Set environment
      - run: echo 'export PATH="/opt/verilator/verilator_4_016/bin:/opt/yosys/bin:$PATH"' >> $BASH_ENV

      # The -DminimalResources flag causes sbt to run tests sequentially,
      #  so we could actually use "sbt +test" to run all the crossVersioned tests.
      # We currently run them separately so we can run them in parallel.
      - run:
          command: |
            (cd chisel3 && cat /dev/null | sbt $SBT_ARGS -DminimalResources << parameters.scalaVersion >> test)

jobs:
  build-prep:
    executor: chisel-executor

    steps:

    # Perform a "default" checkout to get ssh set up.
      - checkout:
          path: chisel3

      - run:
          command: |
            date > date.prep
            printenv
            ls -l
            git clone --depth 10 --branch $FIRRTL_BRANCH "$FIRRTL_REPO" firrtl && (cd firrtl && git checkout $FIRRTL_REV)
            echo $FIRRTL_REV && (cd firrtl && git log -1 > ../firrtl.log)
            git clone --depth 10 --branch $TREADLE_BRANCH "$TREADLE_REPO" treadle && (cd treadle && git checkout $TREADLE_REV)
            echo $TREADLE_REV && (cd treadle && git log -1 > ../treadle.log)


      - persist_to_workspace:
          root: /home/chisel
          paths:
            - repo
            - .ivy2
            - .m2
            - .sbt

  build-firrtl:
    executor: chisel-executor

    steps:
      - attach_workspace:
          at: /home/chisel

      # publish FIRRTL
      - run:
          command: |
            date > date.firrtl
            (cd firrtl && cat /dev/null | sbt $SBT_ARGS +publishLocal)

      - persist_to_workspace:
          root: /home/chisel
          paths:
            - repo
            - .ivy2
            - .m2
            - .sbt

  build-treadle:
    executor: chisel-executor

    steps:
      - attach_workspace:
          at: /home/chisel

      # publish Treadle
      - run:
          command: |
            date > date.treadle
            (cd treadle && cat /dev/null | sbt $SBT_ARGS +publishLocal)

      - persist_to_workspace:
          root: /home/chisel
          paths:
            - repo
            - .ivy2
            - .m2
            - .sbt

  # Define a pure build chisel - currently unused since we can compile and test chisel in one step
  #  and we don't have downstream jobs that need the published version of chisel.
  build-chisel:
    executor: chisel-executor

    steps:
      - attach_workspace:
          at: /home/chisel

      # publish chisel
      - run: date > date.chisel3 && (cd chisel3 && cat /dev/null | sbt $SBT_ARGS +publishLocal)

      - persist_to_workspace:
          root: /home/chisel
          paths:
            - repo
            - .ivy2
            - .m2
            - .sbt

  test-chisel-2_11:
    executor: chisel-executor
    steps:
      - test-chisel:
          scalaVersion: "++2.11.12"

  test-chisel-2_12:
    executor: chisel-executor
    steps:
      - test-chisel:
          scalaVersion: "++2.12.11"

  checkstyle-chisel:
    executor: chisel-executor
    steps:
      - attach_workspace:
          at: /home/chisel

      - run:
          command: |
            # We expect the "[info]" field from sbt so the warning count will be in column 4
            (cd chisel3 && cat /dev/null | sbt $SBT_ARGS scalastyle | gawk -v WARN_FAIL=2 -e '/scalastyle Found [0-9]+ warnings/ { print $0; if ($4 > ENVIRON["CHECKSTYLE_LIMIT"]) WARN_FAIL=1; else if (WARN_FAIL == 2) WARN_FAIL=0 }' -e 'END { exit WARN_FAIL}')

workflows:

  build_and_test:
    jobs:
      - build-prep
      - build-firrtl:
          requires:
            - build-prep
      - build-treadle:
          requires:
            - build-firrtl
      - test-chisel-2_11:
          requires:
            - build-treadle
      - test-chisel-2_12:
          requires:
            - build-treadle
      - checkstyle-chisel:
          # Strictly speaking, this is only dependent on build-firrtl,
          #  but it is faster than the test jobs so if it fails,
          #  it fails the entire build before we get a chance to complete the tests.
          # If we make it dependent on at least one of the tests,
          #  there's a better chance to see if the tests fail before we flag a style failure
          requires:
            - test-chisel-2_12