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