Show More
@@ -1,231 +1,232 b'' | |||||
1 | # |
|
1 | # | |
2 | # About |
|
2 | # About | |
3 | # ===== |
|
3 | # ===== | |
4 | # |
|
4 | # | |
5 | # This file defines jobs for our CI system and the attribute "build" is used |
|
5 | # This file defines jobs for our CI system and the attribute "build" is used | |
6 | # as the input for packaging. |
|
6 | # as the input for packaging. | |
7 | # |
|
7 | # | |
8 | # |
|
8 | # | |
9 | # CI details |
|
9 | # CI details | |
10 | # ========== |
|
10 | # ========== | |
11 | # |
|
11 | # | |
12 | # This file defines an attribute set of derivations. Each of these attributes is |
|
12 | # This file defines an attribute set of derivations. Each of these attributes is | |
13 | # then used in our CI system as one job to run. This way we keep the |
|
13 | # then used in our CI system as one job to run. This way we keep the | |
14 | # configuration for the CI jobs as well under version control. |
|
14 | # configuration for the CI jobs as well under version control. | |
15 | # |
|
15 | # | |
16 | # Run CI jobs locally |
|
16 | # Run CI jobs locally | |
17 | # ------------------- |
|
17 | # ------------------- | |
18 | # |
|
18 | # | |
19 | # Since it is all based on normal Nix derivations, the jobs can be tested |
|
19 | # Since it is all based on normal Nix derivations, the jobs can be tested | |
20 | # locally with a run of "nix-build" like the following example: |
|
20 | # locally with a run of "nix-build" like the following example: | |
21 | # |
|
21 | # | |
22 | # nix-build release.nix -A test-api -I vcsserver=~/rhodecode-vcsserver |
|
22 | # nix-build release.nix -A test-api -I vcsserver=~/rhodecode-vcsserver | |
23 | # |
|
23 | # | |
24 | # Note: Replace "~/rhodecode-vcsserver" with a path where a clone of the |
|
24 | # Note: Replace "~/rhodecode-vcsserver" with a path where a clone of the | |
25 | # vcsserver resides. |
|
25 | # vcsserver resides. | |
26 |
|
26 | |||
27 | { pkgs ? import <nixpkgs> {} |
|
27 | { pkgs ? import <nixpkgs> {} | |
|
28 | , doCheck ? true | |||
28 | }: |
|
29 | }: | |
29 |
|
30 | |||
30 | let |
|
31 | let | |
31 |
|
32 | |||
32 | inherit (pkgs) |
|
33 | inherit (pkgs) | |
33 | stdenv |
|
34 | stdenv | |
34 | system; |
|
35 | system; | |
35 |
|
36 | |||
36 | testing = import <nixpkgs/nixos/lib/testing.nix> { |
|
37 | testing = import <nixpkgs/nixos/lib/testing.nix> { | |
37 | inherit system; |
|
38 | inherit system; | |
38 | }; |
|
39 | }; | |
39 |
|
40 | |||
40 | runInMachine = testing.runInMachine; |
|
41 | runInMachine = testing.runInMachine; | |
41 |
|
42 | |||
42 | sphinx = import ./docs/default.nix {}; |
|
43 | sphinx = import ./docs/default.nix {}; | |
43 |
|
44 | |||
44 | mkDocs = kind: stdenv.mkDerivation { |
|
45 | mkDocs = kind: stdenv.mkDerivation { | |
45 | name = kind; |
|
46 | name = kind; | |
46 | srcs = [ |
|
47 | srcs = [ | |
47 | (./. + (builtins.toPath "/${kind}")) |
|
48 | (./. + (builtins.toPath "/${kind}")) | |
48 | (builtins.filterSource |
|
49 | (builtins.filterSource | |
49 | (path: type: baseNameOf path == "VERSION") |
|
50 | (path: type: baseNameOf path == "VERSION") | |
50 | ./rhodecode) |
|
51 | ./rhodecode) | |
51 | ]; |
|
52 | ]; | |
52 | sourceRoot = kind; |
|
53 | sourceRoot = kind; | |
53 | buildInputs = [ sphinx ]; |
|
54 | buildInputs = [ sphinx ]; | |
54 | configurePhase = null; |
|
55 | configurePhase = null; | |
55 | buildPhase = '' |
|
56 | buildPhase = '' | |
56 | make SPHINXBUILD=sphinx-build html |
|
57 | make SPHINXBUILD=sphinx-build html | |
57 | ''; |
|
58 | ''; | |
58 | installPhase = '' |
|
59 | installPhase = '' | |
59 | mkdir -p $out |
|
60 | mkdir -p $out | |
60 | mv _build/html $out/ |
|
61 | mv _build/html $out/ | |
61 |
|
62 | |||
62 | mkdir -p $out/nix-support |
|
63 | mkdir -p $out/nix-support | |
63 | echo "doc manual $out/html index.html" >> \ |
|
64 | echo "doc manual $out/html index.html" >> \ | |
64 | "$out/nix-support/hydra-build-products" |
|
65 | "$out/nix-support/hydra-build-products" | |
65 | ''; |
|
66 | ''; | |
66 | }; |
|
67 | }; | |
67 |
|
68 | |||
68 | enterprise = import ./default.nix { |
|
69 | enterprise = import ./default.nix { | |
69 | inherit |
|
70 | inherit | |
70 | pkgs; |
|
71 | pkgs; | |
71 |
|
72 | |||
72 | # TODO: for quick local testing |
|
73 | # TODO: for quick local testing | |
73 | doCheck = false; |
|
74 | doCheck = false; | |
74 | }; |
|
75 | }; | |
75 |
|
76 | |||
76 | test-cfg = stdenv.mkDerivation { |
|
77 | test-cfg = stdenv.mkDerivation { | |
77 | name = "test-cfg"; |
|
78 | name = "test-cfg"; | |
78 | unpackPhase = "true"; |
|
79 | unpackPhase = "true"; | |
79 | buildInputs = [ |
|
80 | buildInputs = [ | |
80 | enterprise.src |
|
81 | enterprise.src | |
81 | ]; |
|
82 | ]; | |
82 | installPhase = '' |
|
83 | installPhase = '' | |
83 | mkdir -p $out/etc |
|
84 | mkdir -p $out/etc | |
84 | cp ${enterprise.src}/test.ini $out/etc/enterprise.ini |
|
85 | cp ${enterprise.src}/test.ini $out/etc/enterprise.ini | |
85 | # TODO: johbo: Needed, so that the login works, this causes |
|
86 | # TODO: johbo: Needed, so that the login works, this causes | |
86 | # probably some side effects |
|
87 | # probably some side effects | |
87 | substituteInPlace $out/etc/enterprise.ini --replace "is_test = True" "" |
|
88 | substituteInPlace $out/etc/enterprise.ini --replace "is_test = True" "" | |
88 |
|
89 | |||
89 | # Gevent configuration |
|
90 | # Gevent configuration | |
90 | cp $out/etc/enterprise.ini $out/etc/enterprise-gevent.ini; |
|
91 | cp $out/etc/enterprise.ini $out/etc/enterprise-gevent.ini; | |
91 | cat >> $out/etc/enterprise-gevent.ini <<EOF |
|
92 | cat >> $out/etc/enterprise-gevent.ini <<EOF | |
92 |
|
93 | |||
93 | [server:main] |
|
94 | [server:main] | |
94 | use = egg:gunicorn#main |
|
95 | use = egg:gunicorn#main | |
95 | worker_class = gevent |
|
96 | worker_class = gevent | |
96 | EOF |
|
97 | EOF | |
97 |
|
98 | |||
98 | cp ${enterprise.src}/vcsserver/test.ini $out/etc/vcsserver.ini |
|
99 | cp ${enterprise.src}/vcsserver/test.ini $out/etc/vcsserver.ini | |
99 | ''; |
|
100 | ''; | |
100 | }; |
|
101 | }; | |
101 |
|
102 | |||
102 | ac-test-drv = import ./acceptance_tests { |
|
103 | ac-test-drv = import ./acceptance_tests { | |
103 | withExternals = false; |
|
104 | withExternals = false; | |
104 | }; |
|
105 | }; | |
105 |
|
106 | |||
106 | # TODO: johbo: Currently abusing buildPythonPackage to make the |
|
107 | # TODO: johbo: Currently abusing buildPythonPackage to make the | |
107 | # needed environment for the ac-test tools. |
|
108 | # needed environment for the ac-test tools. | |
108 | mkAcTests = { |
|
109 | mkAcTests = { | |
109 | # Path to an INI file which will be used to run Enterprise. |
|
110 | # Path to an INI file which will be used to run Enterprise. | |
110 | # |
|
111 | # | |
111 | # Intended usage is to provide different configuration files to |
|
112 | # Intended usage is to provide different configuration files to | |
112 | # run the tests against a different configuration. |
|
113 | # run the tests against a different configuration. | |
113 | enterpriseCfg ? "${test-cfg}/etc/enterprise.ini" |
|
114 | enterpriseCfg ? "${test-cfg}/etc/enterprise.ini" | |
114 |
|
115 | |||
115 | # Path to an INI file which will be used to run the VCSServer. |
|
116 | # Path to an INI file which will be used to run the VCSServer. | |
116 | , vcsserverCfg ? "${test-cfg}/etc/vcsserver.ini" |
|
117 | , vcsserverCfg ? "${test-cfg}/etc/vcsserver.ini" | |
117 | }: pkgs.pythonPackages.buildPythonPackage { |
|
118 | }: pkgs.pythonPackages.buildPythonPackage { | |
118 | name = "enterprise-ac-tests"; |
|
119 | name = "enterprise-ac-tests"; | |
119 | src = ./acceptance_tests; |
|
120 | src = ./acceptance_tests; | |
120 |
|
121 | |||
121 | buildInputs = with pkgs; [ |
|
122 | buildInputs = with pkgs; [ | |
122 | curl |
|
123 | curl | |
123 | enterprise |
|
124 | enterprise | |
124 | ac-test-drv |
|
125 | ac-test-drv | |
125 | ]; |
|
126 | ]; | |
126 |
|
127 | |||
127 | buildPhase = '' |
|
128 | buildPhase = '' | |
128 | cp ${enterpriseCfg} enterprise.ini |
|
129 | cp ${enterpriseCfg} enterprise.ini | |
129 |
|
130 | |||
130 | echo "Creating a fake home directory" |
|
131 | echo "Creating a fake home directory" | |
131 | mkdir fake-home |
|
132 | mkdir fake-home | |
132 | export HOME=$PWD/fake-home |
|
133 | export HOME=$PWD/fake-home | |
133 |
|
134 | |||
134 | echo "Creating a repository directory" |
|
135 | echo "Creating a repository directory" | |
135 | mkdir repos |
|
136 | mkdir repos | |
136 |
|
137 | |||
137 | echo "Preparing the database" |
|
138 | echo "Preparing the database" | |
138 | paster setup-rhodecode \ |
|
139 | paster setup-rhodecode \ | |
139 | --user=admin \ |
|
140 | --user=admin \ | |
140 | --email=admin@example.com \ |
|
141 | --email=admin@example.com \ | |
141 | --password=secret \ |
|
142 | --password=secret \ | |
142 | --api-key=9999999999999999999999999999999999999999 \ |
|
143 | --api-key=9999999999999999999999999999999999999999 \ | |
143 | --force-yes \ |
|
144 | --force-yes \ | |
144 | --repos=$PWD/repos \ |
|
145 | --repos=$PWD/repos \ | |
145 | enterprise.ini > /dev/null |
|
146 | enterprise.ini > /dev/null | |
146 |
|
147 | |||
147 | echo "Starting rcserver" |
|
148 | echo "Starting rcserver" | |
148 | vcsserver --config ${vcsserverCfg} >vcsserver.log 2>&1 & |
|
149 | vcsserver --config ${vcsserverCfg} >vcsserver.log 2>&1 & | |
149 | rcserver enterprise.ini >rcserver.log 2>&1 & |
|
150 | rcserver enterprise.ini >rcserver.log 2>&1 & | |
150 |
|
151 | |||
151 | while ! curl -f -s http://localhost:5000 > /dev/null |
|
152 | while ! curl -f -s http://localhost:5000 > /dev/null | |
152 | do |
|
153 | do | |
153 | echo "Waiting for server to be ready..." |
|
154 | echo "Waiting for server to be ready..." | |
154 | sleep 3 |
|
155 | sleep 3 | |
155 | done |
|
156 | done | |
156 | echo "Webserver is ready." |
|
157 | echo "Webserver is ready." | |
157 |
|
158 | |||
158 | echo "Starting the test run" |
|
159 | echo "Starting the test run" | |
159 | py.test -c example.ini -vs --maxfail=5 tests |
|
160 | py.test -c example.ini -vs --maxfail=5 tests | |
160 |
|
161 | |||
161 | echo "Kill rcserver" |
|
162 | echo "Kill rcserver" | |
162 | kill %2 |
|
163 | kill %2 | |
163 | kill %1 |
|
164 | kill %1 | |
164 | ''; |
|
165 | ''; | |
165 |
|
166 | |||
166 | # TODO: johbo: Use the install phase again once the normal mkDerivation |
|
167 | # TODO: johbo: Use the install phase again once the normal mkDerivation | |
167 | # can be used again. |
|
168 | # can be used again. | |
168 | postInstall = '' |
|
169 | postInstall = '' | |
169 | mkdir -p $out |
|
170 | mkdir -p $out | |
170 | cp enterprise.ini $out |
|
171 | cp enterprise.ini $out | |
171 | cp ${vcsserverCfg} $out/vcsserver.ini |
|
172 | cp ${vcsserverCfg} $out/vcsserver.ini | |
172 | cp rcserver.log $out |
|
173 | cp rcserver.log $out | |
173 | cp vcsserver.log $out |
|
174 | cp vcsserver.log $out | |
174 |
|
175 | |||
175 | mkdir -p $out/nix-support |
|
176 | mkdir -p $out/nix-support | |
176 | echo "report config $out enterprise.ini" >> $out/nix-support/hydra-build-products |
|
177 | echo "report config $out enterprise.ini" >> $out/nix-support/hydra-build-products | |
177 | echo "report config $out vcsserver.ini" >> $out/nix-support/hydra-build-products |
|
178 | echo "report config $out vcsserver.ini" >> $out/nix-support/hydra-build-products | |
178 | echo "report rcserver $out rcserver.log" >> $out/nix-support/hydra-build-products |
|
179 | echo "report rcserver $out rcserver.log" >> $out/nix-support/hydra-build-products | |
179 | echo "report vcsserver $out vcsserver.log" >> $out/nix-support/hydra-build-products |
|
180 | echo "report vcsserver $out vcsserver.log" >> $out/nix-support/hydra-build-products | |
180 | ''; |
|
181 | ''; | |
181 | }; |
|
182 | }; | |
182 |
|
183 | |||
183 | vcsserver = import <vcsserver> { |
|
184 | vcsserver = import <vcsserver> { | |
184 | inherit pkgs; |
|
185 | inherit pkgs; | |
185 |
|
186 | |||
186 | # TODO: johbo: Think of a more elegant solution to this problem |
|
187 | # TODO: johbo: Think of a more elegant solution to this problem | |
187 | pythonExternalOverrides = self: super: (enterprise.myPythonPackagesUnfix self); |
|
188 | pythonExternalOverrides = self: super: (enterprise.myPythonPackagesUnfix self); | |
188 | }; |
|
189 | }; | |
189 |
|
190 | |||
190 | runTests = optionString: (enterprise.override (attrs: { |
|
191 | runTests = optionString: (enterprise.override (attrs: { | |
191 | doCheck = true; |
|
192 | doCheck = true; | |
192 | name = "test-run"; |
|
193 | name = "test-run"; | |
193 | buildInputs = attrs.buildInputs ++ [ |
|
194 | buildInputs = attrs.buildInputs ++ [ | |
194 | vcsserver |
|
195 | vcsserver | |
195 | ]; |
|
196 | ]; | |
196 | checkPhase = '' |
|
197 | checkPhase = '' | |
197 | py.test ${optionString} -vv -ra |
|
198 | py.test ${optionString} -vv -ra | |
198 | ''; |
|
199 | ''; | |
199 | buildPhase = attrs.shellHook; |
|
200 | buildPhase = attrs.shellHook; | |
200 | installPhase = '' |
|
201 | installPhase = '' | |
201 | echo "Intentionally not installing anything" |
|
202 | echo "Intentionally not installing anything" | |
202 | ''; |
|
203 | ''; | |
203 | meta.description = "Enterprise test run ${optionString}"; |
|
204 | meta.description = "Enterprise test run ${optionString}"; | |
204 | })); |
|
205 | })); | |
205 |
|
206 | |||
206 | jobs = { |
|
207 | jobs = { | |
207 |
|
208 | |||
208 | build = enterprise; |
|
209 | build = enterprise; | |
209 |
|
210 | |||
210 | # johbo: Currently this is simply running the tests against the sources. Nicer |
|
211 | # johbo: Currently this is simply running the tests against the sources. Nicer | |
211 | # would be to run xdist and against the installed application, so that we also |
|
212 | # would be to run xdist and against the installed application, so that we also | |
212 | # cover the impact of installing the application. |
|
213 | # cover the impact of installing the application. | |
213 | test-api = runTests "rhodecode/api"; |
|
214 | test-api = runTests "rhodecode/api"; | |
214 | test-functional = runTests "rhodecode/tests/functional"; |
|
215 | test-functional = runTests "rhodecode/tests/functional"; | |
215 | test-rest = runTests "rhodecode/tests --ignore=rhodecode/tests/functional"; |
|
216 | test-rest = runTests "rhodecode/tests --ignore=rhodecode/tests/functional"; | |
216 | test-full = runTests "rhodecode"; |
|
217 | test-full = runTests "rhodecode"; | |
217 |
|
218 | |||
218 | docs = mkDocs "docs"; |
|
219 | docs = mkDocs "docs"; | |
219 |
|
220 | |||
220 | aggregate = pkgs.releaseTools.aggregate { |
|
221 | aggregate = pkgs.releaseTools.aggregate { | |
221 | name = "aggregated-jobs"; |
|
222 | name = "aggregated-jobs"; | |
222 | constituents = [ |
|
223 | constituents = [ | |
223 | jobs.build |
|
224 | jobs.build | |
224 | jobs.test-api |
|
225 | jobs.test-api | |
225 | jobs.test-rest |
|
226 | jobs.test-rest | |
226 | jobs.docs |
|
227 | jobs.docs | |
227 | ]; |
|
228 | ]; | |
228 | }; |
|
229 | }; | |
229 | }; |
|
230 | }; | |
230 |
|
231 | |||
231 | in jobs |
|
232 | in jobs |
General Comments 0
You need to be logged in to leave comments.
Login now