diff --git a/tests/commands/push.spec.ts b/tests/commands/push.spec.ts index c13d13701a..1a0e91efcf 100644 --- a/tests/commands/push.spec.ts +++ b/tests/commands/push.spec.ts @@ -409,6 +409,59 @@ describe('balena push', function () { }); }); + it('should create the expected tar stream (single container, symbolic links in docker-compose, --gitignore)', async () => { + const projectPath = path.join( + projectsPath, + 'docker-compose', + 'symbolic-links', + ); + const expectedFiles: ExpectedTarStreamFiles = { + '.balena/balena.yml': { fileSize: 197, type: 'file' }, + 'docker-compose.yml': { fileSize: 340, type: 'file' }, + 'service1/Dockerfile.template': { fileSize: 144, type: 'file' }, + 'service1/file1.sh': { fileSize: 12, type: 'file' }, + 'service1/test-ignore-from-symlink-path.txt': { + fileSize: 12, + type: 'file', + }, + 'service2/Dockerfile-alt': { fileSize: 13, type: 'file' }, + 'service2/src/file1.sh': { fileSize: 12, type: 'file' }, + }; + const regSecretsPath = await addRegSecretsEntries(expectedFiles); + const responseFilename = 'build-POST-v3.json'; + const responseBody = await fs.readFile( + path.join(builderResponsePath, responseFilename), + 'utf8', + ); + const expectedResponseLines: string[] = [ + ...commonResponseLines[responseFilename], + ...getDockerignoreWarn1( + [path.join(projectPath, 'service2', '.dockerignore')], + 'push', + ), + ]; + if (isWindows) { + expectedResponseLines.push( + `[Info] Converting line endings CRLF -> LF for file: ${path.join( + projectPath, + 'service2', + 'file2-crlf.sh', + )}`, + ); + } + + await testPushBuildStream({ + builderMock: builder, + commandLine: `push testApp -s ${projectPath} -R ${regSecretsPath}`, + expectedFiles, + expectedQueryParams: commonQueryParams, + expectedResponseLines, + projectPath, + responseBody, + responseCode: 200, + }); + }); + it('should create the expected tar stream (single container, --multi-dockerignore)', async () => { const projectPath = path.join( projectsPath, diff --git a/tests/test-data/projects/docker-compose/symbolic-links/.balena/balena.yml b/tests/test-data/projects/docker-compose/symbolic-links/.balena/balena.yml new file mode 100644 index 0000000000..ef6db889e6 --- /dev/null +++ b/tests/test-data/projects/docker-compose/symbolic-links/.balena/balena.yml @@ -0,0 +1,7 @@ +build-variables: + global: + - MY_VAR_1=This is a variable + - MY_VAR_2=Also a variable + services: + service1: + - SERVICE1_VAR=This is a service specific variable diff --git a/tests/test-data/projects/docker-compose/symbolic-links/.dockerignore b/tests/test-data/projects/docker-compose/symbolic-links/.dockerignore new file mode 100644 index 0000000000..a0da95ebf0 --- /dev/null +++ b/tests/test-data/projects/docker-compose/symbolic-links/.dockerignore @@ -0,0 +1,3 @@ +service1/test-ignore-from-actual-path.* +service1-symlink/test-ignore-from-symlink-path.* +**/.dockerignore diff --git a/tests/test-data/projects/docker-compose/symbolic-links/docker-compose.yml b/tests/test-data/projects/docker-compose/symbolic-links/docker-compose.yml new file mode 100644 index 0000000000..867a1252ab --- /dev/null +++ b/tests/test-data/projects/docker-compose/symbolic-links/docker-compose.yml @@ -0,0 +1,16 @@ +version: '2' +volumes: + resin-data: +services: + service1: + volumes: + - 'resin-data:/data' + build: ./service1-symlink + service2: + volumes: + - 'resin-data:/data' + build: + context: ./service2 + dockerfile: Dockerfile-alt + args: + - 'COMPOSE_ARG=an argument defined in the docker-compose.yml file' diff --git a/tests/test-data/projects/docker-compose/symbolic-links/service1 b/tests/test-data/projects/docker-compose/symbolic-links/service1 new file mode 120000 index 0000000000..1257fe7d57 --- /dev/null +++ b/tests/test-data/projects/docker-compose/symbolic-links/service1 @@ -0,0 +1 @@ +../symlink-fixtures/service1/ \ No newline at end of file diff --git a/tests/test-data/projects/docker-compose/symbolic-links/service2/.dockerignore b/tests/test-data/projects/docker-compose/symbolic-links/service2/.dockerignore new file mode 100644 index 0000000000..08012d02d2 --- /dev/null +++ b/tests/test-data/projects/docker-compose/symbolic-links/service2/.dockerignore @@ -0,0 +1 @@ +**/file1.sh diff --git a/tests/test-data/projects/docker-compose/symbolic-links/service2/Dockerfile-alt b/tests/test-data/projects/docker-compose/symbolic-links/service2/Dockerfile-alt new file mode 100644 index 0000000000..24a79d08b6 --- /dev/null +++ b/tests/test-data/projects/docker-compose/symbolic-links/service2/Dockerfile-alt @@ -0,0 +1 @@ +FROM busybox diff --git a/tests/test-data/projects/docker-compose/symbolic-links/service2/src/file1.sh b/tests/test-data/projects/docker-compose/symbolic-links/service2/src/file1.sh new file mode 100644 index 0000000000..c0d0fb45c3 --- /dev/null +++ b/tests/test-data/projects/docker-compose/symbolic-links/service2/src/file1.sh @@ -0,0 +1,2 @@ +line1 +line2 diff --git a/tests/test-data/projects/docker-compose/symlink-fixtures/service1/Dockerfile.template b/tests/test-data/projects/docker-compose/symlink-fixtures/service1/Dockerfile.template new file mode 100644 index 0000000000..f3cf876814 --- /dev/null +++ b/tests/test-data/projects/docker-compose/symlink-fixtures/service1/Dockerfile.template @@ -0,0 +1,3 @@ +FROM balenalib/%%BALENA_MACHINE_NAME%%-alpine +COPY ./file1.sh / +CMD i=1; while :; do echo "service1 $i $(uname -a)"; sleep 10; i=$((i+1)); done diff --git a/tests/test-data/projects/docker-compose/symlink-fixtures/service1/file1.sh b/tests/test-data/projects/docker-compose/symlink-fixtures/service1/file1.sh new file mode 100644 index 0000000000..c0d0fb45c3 --- /dev/null +++ b/tests/test-data/projects/docker-compose/symlink-fixtures/service1/file1.sh @@ -0,0 +1,2 @@ +line1 +line2 diff --git a/tests/test-data/projects/docker-compose/symlink-fixtures/service1/test-ignore-from-actual-path.txt b/tests/test-data/projects/docker-compose/symlink-fixtures/service1/test-ignore-from-actual-path.txt new file mode 100644 index 0000000000..47e97a9910 --- /dev/null +++ b/tests/test-data/projects/docker-compose/symlink-fixtures/service1/test-ignore-from-actual-path.txt @@ -0,0 +1 @@ +test-ignore diff --git a/tests/test-data/projects/docker-compose/symlink-fixtures/service1/test-ignore-from-symlink-path.txt b/tests/test-data/projects/docker-compose/symlink-fixtures/service1/test-ignore-from-symlink-path.txt new file mode 100644 index 0000000000..47e97a9910 --- /dev/null +++ b/tests/test-data/projects/docker-compose/symlink-fixtures/service1/test-ignore-from-symlink-path.txt @@ -0,0 +1 @@ +test-ignore