1version: 2
2
3jobs:
4  # the first half of the jobs are in this test
5  short-tests-0:
6    # TODO: Create a small custom docker image with all the dependencies we need
7    #       preinstalled to reduce installation time.
8    docker:
9      - image: fbopensource/zstd-circleci-primary:0.0.1
10    steps:
11      - checkout
12      - run:
13          name: Test
14          command: |
15            ./tests/test-license.py
16            cc -v; CFLAGS="-O0 -Werror -pedantic" make all && make clean
17            make c99build         ; make clean
18            make c11build         ; make clean
19            make aarch64build     ; make clean
20            make -j regressiontest; make clean
21            make shortest         ; make clean
22            make cxxtest          ; make clean
23  # the second half of the jobs are in this test
24  short-tests-1:
25    docker:
26      - image: fbopensource/zstd-circleci-primary:0.0.1
27    steps:
28      - checkout
29      - run:
30          name: Test
31          command: |
32            make gnu90build; make clean
33            make gnu99build; make clean
34            make ppc64build V=1; make clean
35            make ppcbuild   V=1; make clean
36            make armbuild   V=1; make clean
37            make -C tests test-legacy test-longmatch; make clean
38            make -C lib libzstd-nomt; make clean
39  # This step should only be run in a cron job
40  regression-test:
41    docker:
42      - image: fbopensource/zstd-circleci-primary:0.0.1
43    environment:
44      CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
45    steps:
46      - checkout
47      # Restore the cached resources.
48      - restore_cache:
49          # We try our best to bust the cache when the data changes by hashing
50          # data.c. If that doesn't work, simply update the version number here
51          # and below. If we fail to bust the cache, the regression testing will
52          # still work, since it has its own stamp, but will need to redownload
53          # everything.
54          keys:
55            - regression-cache-{{ checksum "tests/regression/data.c" }}-v0
56      - run:
57          name: Regression Test
58          command: |
59            make -C programs zstd
60            make -C tests/regression test
61            mkdir -p $CIRCLE_ARTIFACTS
62            ./tests/regression/test                     \
63                --cache  tests/regression/cache         \
64                --output $CIRCLE_ARTIFACTS/results.csv  \
65                --zstd   programs/zstd
66            echo "NOTE: The new results.csv is uploaded as an artifact to this job"
67            echo "      If this fails, go to the Artifacts pane in CircleCI, "
68            echo "      download /tmp/circleci-artifacts/results.csv, and if they "
69            echo "      are still good, copy it into the repo and commit it."
70            echo "> diff tests/regression/results.csv $CIRCLE_ARTIFACTS/results.csv"
71            diff tests/regression/results.csv $CIRCLE_ARTIFACTS/results.csv
72      # Only save the cache on success (default), since if the failure happened
73      # before we stamp the data cache, we will have a bad cache for this key.
74      - save_cache:
75          key: regression-cache-{{ checksum "tests/regression/data.c" }}-v0
76          paths:
77            - tests/regression/cache
78      - store_artifacts:
79          path: /tmp/circleci-artifacts
80
81
82workflows:
83  version: 2
84  commit:
85    jobs:
86      # Run the tests in parallel
87      - short-tests-0:
88          filters:
89            tags:
90              only: /.*/
91      - short-tests-1:
92          filters:
93            tags:
94              only: /.*/
95      # Create a branch called regression and set it to dev to force a
96      # regression test run
97      - regression-test:
98          filters:
99            branches:
100              only:
101                - regression
102      # Only run on release tags.
103      - publish-github-release:
104          requires:
105            - short-tests-0
106            - short-tests-1
107          filters:
108            branches:
109              ignore: /.*/
110            tags:
111              only: /^v\d+\.\d+\.\d+$/
112  nightly:
113    triggers:
114      - schedule:
115          cron: "0 0 * * *"
116          filters:
117            branches:
118              only:
119                - release
120                - dev
121                - master
122    jobs:
123      # Run daily long regression tests
124      - regression-test
125
126
127
128  # Longer tests
129    #- make -C tests test-zstd-nolegacy && make clean
130    #- pyenv global 3.4.4; make -C tests versionsTest && make clean
131    #- make zlibwrapper         && make clean
132    #- gcc -v; make -C tests test32 MOREFLAGS="-I/usr/include/x86_64-linux-gnu" && make clean
133    #- make uasan               && make clean
134    #- make asan32              && make clean
135    #- make -C tests test32 CC=clang MOREFLAGS="-g -fsanitize=address -I/usr/include/x86_64-linux-gnu"
136  # Valgrind tests
137    #- CFLAGS="-O1 -g" make -C zlibWrapper valgrindTest && make clean
138    #- make -C tests valgrindTest && make clean
139  # ARM, AArch64, PowerPC, PowerPC64 tests
140    #- make ppctest             && make clean
141    #- make ppc64test           && make clean
142    #- make armtest             && make clean
143    #- make aarch64test         && make clean
144