This repository was archived by the owner on Jan 25, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 9 files changed +137
-6
lines changed Expand file tree Collapse file tree 9 files changed +137
-6
lines changed Original file line number Diff line number Diff line change 1
1
tmp /
2
+ node_modules
Original file line number Diff line number Diff line change 8
8
steps :
9
9
- uses : actions/checkout@v2
10
10
- name : Build Docker image
11
- run : docker build . --build-arg NF_IMAGE_VERSION=$GITHUB_SHA -t netlify/build:$GITHUB_SHA
11
+ run : docker build . --build-arg NF_IMAGE_VERSION=$GITHUB_SHA --target build-image -t netlify/build:$GITHUB_SHA
12
12
- uses : vbrown608/whalescale@v1
13
13
with :
14
14
token : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 1
- FROM ubuntu:16.04
1
+ FROM ubuntu:16.04 as build-image
2
2
3
3
LABEL maintainer Netlify
4
4
@@ -262,6 +262,7 @@ RUN git clone https://github.com/creationix/nvm.git ~/.nvm && \
262
262
git checkout v$NVM_VERSION && \
263
263
cd /
264
264
265
+ # Install node.js, yarn, bower and elm
265
266
ENV ELM_VERSION=0.19.0-bugfix6
266
267
ENV YARN_VERSION=1.22.10
267
268
@@ -499,3 +500,23 @@ ENV NF_IMAGE_VERSION ${NF_IMAGE_VERSION:-latest}
499
500
500
501
ARG NF_IMAGE_TAG
501
502
ENV NF_IMAGE_TAG ${NF_IMAGE_TAG:-latest}
503
+
504
+
505
+ # ###############################################################################
506
+ #
507
+ # Test stage Dockerfile
508
+ #
509
+ # ###############################################################################
510
+
511
+ FROM build-image as build-image-test
512
+
513
+ USER buildbot
514
+ SHELL ["/bin/bash" , "-c" ]
515
+
516
+ ADD --chown=buildbot package.json /opt/buildhome/test-env/package.json
517
+ RUN cd /opt/buildhome/test-env && . ~/.nvm/nvm.sh && npm i &&\
518
+ ln -s /opt/build-bin/run-build-functions.sh /opt/buildhome/test-env/run-build-functions.sh &&\
519
+ ln -s /opt/build-bin/build /opt/buildhome/test-env/run-build.sh
520
+ ADD --chown=buildbot tests /opt/buildhome/test-env/tests
521
+ WORKDIR /opt/buildhome/test-env
522
+ CMD . ~/.nvm/nvm.sh && npm test
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ pipeline {
16
16
anyOf { branch ' staging' ; branch ' xenial' ; branch ' trusty' ; buildingTag() }
17
17
}
18
18
steps {
19
- sh " docker build --build-arg NF_IMAGE_VERSION=${ env.GIT_COMMIT} --build-arg NF_IMAGE_TAG=${ env.BRANCH_NAME} -t netlify/build:${ env.BRANCH_NAME} -t netlify/build:${ env.GIT_COMMIT} ."
19
+ sh " docker build --build-arg NF_IMAGE_VERSION=${ env.GIT_COMMIT} --build-arg NF_IMAGE_TAG=${ env.BRANCH_NAME} -t netlify/build:${ env.BRANCH_NAME} -t netlify/build:${ env.GIT_COMMIT} --target build-image ."
20
20
}
21
21
}
22
22
@@ -25,7 +25,7 @@ pipeline {
25
25
anyOf { buildingTag() }
26
26
}
27
27
steps {
28
- sh " docker build --build-arg NF_IMAGE_VERSION=${ env.GIT_COMMIT} --build-arg NF_IMAGE_TAG=${ env.BRANCH_NAME} --squash -t netlify/build:${ env.BRANCH_NAME} -squash ."
28
+ sh " docker build --build-arg NF_IMAGE_VERSION=${ env.GIT_COMMIT} --build-arg NF_IMAGE_TAG=${ env.BRANCH_NAME} --squash -t netlify/build:${ env.BRANCH_NAME} -squash --target build-image ."
29
29
}
30
30
}
31
31
Original file line number Diff line number Diff line change 4
4
"description" : " This repository contains the tools to make the build image Netlify uses to build a site from git (for continuous deployment)" ,
5
5
"main" : " index.js" ,
6
6
"private" : " true" ,
7
- "scripts" : {},
7
+ "scripts" : {
8
+ "test" : " bats --recursive --timing --tap tests"
9
+ },
8
10
"repository" : {
9
11
"type" : " git" ,
10
12
"url" : " git+https://github.com/netlify/build-image.git"
15
17
"url" : " https://github.com/netlify/build-image/issues"
16
18
},
17
19
"homepage" : " https://github.com/netlify/build-image#readme" ,
18
- "devDependencies" : {}
20
+ "devDependencies" : {
21
+ "bats" : " ^1.3.0-alpha.0" ,
22
+ "bats-assert" : " ^2.0.0" ,
23
+ "bats-support" : " ^0.3.0" ,
24
+ "bats-file" : " git+https://github.com/bats-core/bats-file.git#v0.3.0"
25
+ },
26
+ "dependencies" : {}
19
27
}
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Sets a given fixture as the project to be used as the target repository for our build-image scripts.
4
+ # It expects a fixture name which should be present in a relative dir named `./fixtures` from the bats test executing it.
5
+ # It sets the global `NETLIFY_BUILD_BASE`, `NETLIFY_CACHE_DIR` and `NETLIFY_REPO_DIR` variables based on the provided directory.
6
+
7
+ # Arguments:
8
+ # $1 - fixture name
9
+ # $2 - path to use as the repo base (ideally a temporary dir)
10
+ set_fixture_as_repo () {
11
+ local fixture=" $1 "
12
+ local tmp_dir=" $2 "
13
+ NETLIFY_BUILD_BASE=$tmp_dir
14
+ NETLIFY_CACHE_DIR=" $NETLIFY_BUILD_BASE /cache"
15
+ NETLIFY_REPO_DIR=" $NETLIFY_BUILD_BASE /repo"
16
+ rm -rf " $NETLIFY_REPO_DIR "
17
+ cp -r " $BATS_TEST_DIRNAME /fixtures/$fixture " " $NETLIFY_REPO_DIR "
18
+
19
+ # Change to the repo dir
20
+ cd " $NETLIFY_REPO_DIR " || exit 1
21
+ }
22
+
23
+ # Setups a tmp dir to be used for test purposes.
24
+ setup_tmp_dir () {
25
+ mktemp -d
26
+ }
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bats
2
+
3
+ load " ../helpers.sh"
4
+
5
+ load ' ../../node_modules/bats-support/load'
6
+ load ' ../../node_modules/bats-assert/load'
7
+
8
+
9
+ NODE_VERSION=12.18.0
10
+
11
+ # Note: These binaries are accessible because we source `~/.nvm/nvm.sh` before running the `bats` tests
12
+
13
+ @test ' node version ${NODE_VERSION} is installed and available at startup' {
14
+ run node --version
15
+ assert_success
16
+ assert_output --partial $NODE_VERSION
17
+ }
18
+
19
+ @test ' grunt-cli is installed and available at startup' {
20
+ run grunt --version
21
+ assert_success
22
+ }
23
+
24
+ @test ' bower is installed and available at startup' {
25
+ run bower --version
26
+ assert_success
27
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " simple-node-project" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " " ,
5
+ "main" : " index.js" ,
6
+ "scripts" : {
7
+ "test" : " echo \" Error: no test specified\" && exit 1"
8
+ },
9
+ "author" : " " ,
10
+ "license" : " UNLICENSED" ,
11
+ "dependencies" : {
12
+ "@netlify/plugins-list" : " ^3.6.0"
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bats
2
+
3
+ load " ../helpers.sh"
4
+
5
+ load ' ../../node_modules/bats-support/load'
6
+ load ' ../../node_modules/bats-assert/load'
7
+ load ' ../../node_modules/bats-file/load'
8
+
9
+ YARN_CACHE_DIR=/opt/buildhome/.yarn_cache
10
+
11
+ setup () {
12
+ TMP_DIR=$( setup_tmp_dir)
13
+ set_fixture_as_repo ' simple-node' " $TMP_DIR "
14
+
15
+ # Load functions
16
+ load ' ../../run-build-functions.sh'
17
+ }
18
+
19
+ teardown () {
20
+ rm -rf " $TMP_DIR "
21
+ # Return to original dir
22
+ cd - || return
23
+ }
24
+
25
+ @test ' run_yarn sets up new yarn version if different from the one installed, installs deps and creates cache dir' {
26
+ local newYarnVersion=1.21.0
27
+ run run_yarn $newYarnVersion
28
+ assert_success
29
+ assert_output --partial " Installing yarn at version $newYarnVersion "
30
+ assert_dir_exist $YARN_CACHE_DIR
31
+
32
+ # The cache dir is actually being used
33
+ assert_dir_exist " $YARN_CACHE_DIR /v6"
34
+ }
You can’t perform that action at this time.
0 commit comments