diff --git a/__tests__/fixtures/bake-01-overrides.json b/__tests__/.fixtures/bake-01-overrides.json similarity index 100% rename from __tests__/fixtures/bake-01-overrides.json rename to __tests__/.fixtures/bake-01-overrides.json diff --git a/__tests__/fixtures/bake-01-validate.json b/__tests__/.fixtures/bake-01-validate.json similarity index 100% rename from __tests__/fixtures/bake-01-validate.json rename to __tests__/.fixtures/bake-01-validate.json diff --git a/__tests__/fixtures/bake-01.hcl b/__tests__/.fixtures/bake-01.hcl similarity index 100% rename from __tests__/fixtures/bake-01.hcl rename to __tests__/.fixtures/bake-01.hcl diff --git a/__tests__/fixtures/bake-02-build.json b/__tests__/.fixtures/bake-02-build.json similarity index 100% rename from __tests__/fixtures/bake-02-build.json rename to __tests__/.fixtures/bake-02-build.json diff --git a/__tests__/fixtures/bake-02.hcl b/__tests__/.fixtures/bake-02.hcl similarity index 100% rename from __tests__/fixtures/bake-02.hcl rename to __tests__/.fixtures/bake-02.hcl diff --git a/__tests__/fixtures/bake-buildx-0.10.4-binaries-cross.json b/__tests__/.fixtures/bake-buildx-0.10.4-binaries-cross.json similarity index 100% rename from __tests__/fixtures/bake-buildx-0.10.4-binaries-cross.json rename to __tests__/.fixtures/bake-buildx-0.10.4-binaries-cross.json diff --git a/__tests__/fixtures/bake-test-docker-action-remote-private.json b/__tests__/.fixtures/bake-test-docker-action-remote-private.json similarity index 100% rename from __tests__/fixtures/bake-test-docker-action-remote-private.json rename to __tests__/.fixtures/bake-test-docker-action-remote-private.json diff --git a/__tests__/fixtures/buildkitd.toml b/__tests__/.fixtures/buildkitd.toml similarity index 100% rename from __tests__/fixtures/buildkitd.toml rename to __tests__/.fixtures/buildkitd.toml diff --git a/__tests__/fixtures/buildx-refs/__group__/1fugf958r4peyg86h6scim5t5 b/__tests__/.fixtures/buildx-refs/__group__/1fugf958r4peyg86h6scim5t5 similarity index 100% rename from __tests__/fixtures/buildx-refs/__group__/1fugf958r4peyg86h6scim5t5 rename to __tests__/.fixtures/buildx-refs/__group__/1fugf958r4peyg86h6scim5t5 diff --git a/__tests__/fixtures/buildx-refs/default/default/36dix0eiv9evr61vrwzn32w7q b/__tests__/.fixtures/buildx-refs/default/default/36dix0eiv9evr61vrwzn32w7q similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/36dix0eiv9evr61vrwzn32w7q rename to __tests__/.fixtures/buildx-refs/default/default/36dix0eiv9evr61vrwzn32w7q diff --git a/__tests__/fixtures/buildx-refs/default/default/49p5r8und2konke5pmlyzqp3n b/__tests__/.fixtures/buildx-refs/default/default/49p5r8und2konke5pmlyzqp3n similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/49p5r8und2konke5pmlyzqp3n rename to __tests__/.fixtures/buildx-refs/default/default/49p5r8und2konke5pmlyzqp3n diff --git a/__tests__/fixtures/buildx-refs/default/default/7pnnqpgacnqq98oa1a1h5sz6t b/__tests__/.fixtures/buildx-refs/default/default/7pnnqpgacnqq98oa1a1h5sz6t similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/7pnnqpgacnqq98oa1a1h5sz6t rename to __tests__/.fixtures/buildx-refs/default/default/7pnnqpgacnqq98oa1a1h5sz6t diff --git a/__tests__/fixtures/buildx-refs/default/default/84p2qpgacnqq98oa1a1h5sz6t b/__tests__/.fixtures/buildx-refs/default/default/84p2qpgacnqq98oa1a1h5sz6t similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/84p2qpgacnqq98oa1a1h5sz6t rename to __tests__/.fixtures/buildx-refs/default/default/84p2qpgacnqq98oa1a1h5sz6t diff --git a/__tests__/fixtures/buildx-refs/default/default/a5s9rlg9cnqq98oa1a1h5sz6t b/__tests__/.fixtures/buildx-refs/default/default/a5s9rlg9cnqq98oa1a1h5sz6t similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/a5s9rlg9cnqq98oa1a1h5sz6t rename to __tests__/.fixtures/buildx-refs/default/default/a5s9rlg9cnqq98oa1a1h5sz6t diff --git a/__tests__/fixtures/buildx-refs/default/default/a8zqzhhv5yiazm396jobsgdw2 b/__tests__/.fixtures/buildx-refs/default/default/a8zqzhhv5yiazm396jobsgdw2 similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/a8zqzhhv5yiazm396jobsgdw2 rename to __tests__/.fixtures/buildx-refs/default/default/a8zqzhhv5yiazm396jobsgdw2 diff --git a/__tests__/fixtures/buildx-refs/default/default/aav2ix4nw5eky66fw045dkylr b/__tests__/.fixtures/buildx-refs/default/default/aav2ix4nw5eky66fw045dkylr similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/aav2ix4nw5eky66fw045dkylr rename to __tests__/.fixtures/buildx-refs/default/default/aav2ix4nw5eky66fw045dkylr diff --git a/__tests__/fixtures/buildx-refs/default/default/dfsz8r57a98zf789pmlyzqp3n b/__tests__/.fixtures/buildx-refs/default/default/dfsz8r57a98zf789pmlyzqp3n similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/dfsz8r57a98zf789pmlyzqp3n rename to __tests__/.fixtures/buildx-refs/default/default/dfsz8r57a98zf789pmlyzqp3n diff --git a/__tests__/fixtures/buildx-refs/default/default/ij71n3ubmhck85d03zdvye5nr b/__tests__/.fixtures/buildx-refs/default/default/ij71n3ubmhck85d03zdvye5nr similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/ij71n3ubmhck85d03zdvye5nr rename to __tests__/.fixtures/buildx-refs/default/default/ij71n3ubmhck85d03zdvye5nr diff --git a/__tests__/fixtures/buildx-refs/default/default/o1ctbgdb1mwekkxocc6filxde b/__tests__/.fixtures/buildx-refs/default/default/o1ctbgdb1mwekkxocc6filxde similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/o1ctbgdb1mwekkxocc6filxde rename to __tests__/.fixtures/buildx-refs/default/default/o1ctbgdb1mwekkxocc6filxde diff --git a/__tests__/fixtures/buildx-refs/default/default/qvb2qy61mspqdyzf8whvjy0x1 b/__tests__/.fixtures/buildx-refs/default/default/qvb2qy61mspqdyzf8whvjy0x1 similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/qvb2qy61mspqdyzf8whvjy0x1 rename to __tests__/.fixtures/buildx-refs/default/default/qvb2qy61mspqdyzf8whvjy0x1 diff --git a/__tests__/fixtures/buildx-refs/default/default/qxu22kx1mrydcjkbl0b0l6es8 b/__tests__/.fixtures/buildx-refs/default/default/qxu22kx1mrydcjkbl0b0l6es8 similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/qxu22kx1mrydcjkbl0b0l6es8 rename to __tests__/.fixtures/buildx-refs/default/default/qxu22kx1mrydcjkbl0b0l6es8 diff --git a/__tests__/fixtures/buildx-refs/default/default/vzxn0jxr44khtq7hc8drtzwjv b/__tests__/.fixtures/buildx-refs/default/default/vzxn0jxr44khtq7hc8drtzwjv similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/vzxn0jxr44khtq7hc8drtzwjv rename to __tests__/.fixtures/buildx-refs/default/default/vzxn0jxr44khtq7hc8drtzwjv diff --git a/__tests__/fixtures/buildx-refs/default/default/w38vcd5fo5cfvfyig77qjec0v b/__tests__/.fixtures/buildx-refs/default/default/w38vcd5fo5cfvfyig77qjec0v similarity index 100% rename from __tests__/fixtures/buildx-refs/default/default/w38vcd5fo5cfvfyig77qjec0v rename to __tests__/.fixtures/buildx-refs/default/default/w38vcd5fo5cfvfyig77qjec0v diff --git a/__tests__/fixtures/buildx-refs/foo/foo0/21hqcxmgxyhugz2m24tmi7xco b/__tests__/.fixtures/buildx-refs/foo/foo0/21hqcxmgxyhugz2m24tmi7xco similarity index 100% rename from __tests__/fixtures/buildx-refs/foo/foo0/21hqcxmgxyhugz2m24tmi7xco rename to __tests__/.fixtures/buildx-refs/foo/foo0/21hqcxmgxyhugz2m24tmi7xco diff --git a/__tests__/fixtures/buildx-refs/foo/foo0/5nm14argzndbc4hw1jx6v9d5k b/__tests__/.fixtures/buildx-refs/foo/foo0/5nm14argzndbc4hw1jx6v9d5k similarity index 100% rename from __tests__/fixtures/buildx-refs/foo/foo0/5nm14argzndbc4hw1jx6v9d5k rename to __tests__/.fixtures/buildx-refs/foo/foo0/5nm14argzndbc4hw1jx6v9d5k diff --git a/__tests__/fixtures/buildx-refs/foo/foo0/7dblgs0dsjm22ti6p53sih6b7 b/__tests__/.fixtures/buildx-refs/foo/foo0/7dblgs0dsjm22ti6p53sih6b7 similarity index 100% rename from __tests__/fixtures/buildx-refs/foo/foo0/7dblgs0dsjm22ti6p53sih6b7 rename to __tests__/.fixtures/buildx-refs/foo/foo0/7dblgs0dsjm22ti6p53sih6b7 diff --git a/__tests__/fixtures/docker-config-auths.json b/__tests__/.fixtures/docker-config-auths.json similarity index 100% rename from __tests__/fixtures/docker-config-auths.json rename to __tests__/.fixtures/docker-config-auths.json diff --git a/__tests__/fixtures/docker-config-proxies.json b/__tests__/.fixtures/docker-config-proxies.json similarity index 100% rename from __tests__/fixtures/docker-config-proxies.json rename to __tests__/.fixtures/docker-config-proxies.json diff --git a/__tests__/fixtures/dockerhub-repoalltags.json b/__tests__/.fixtures/dockerhub-repoalltags.json similarity index 100% rename from __tests__/fixtures/dockerhub-repoalltags.json rename to __tests__/.fixtures/dockerhub-repoalltags.json diff --git a/__tests__/fixtures/dockerhub-repoinfo.json b/__tests__/.fixtures/dockerhub-repoinfo.json similarity index 100% rename from __tests__/fixtures/dockerhub-repoinfo.json rename to __tests__/.fixtures/dockerhub-repoinfo.json diff --git a/__tests__/fixtures/dockerhub-repotags.json b/__tests__/.fixtures/dockerhub-repotags.json similarity index 100% rename from __tests__/fixtures/dockerhub-repotags.json rename to __tests__/.fixtures/dockerhub-repotags.json diff --git a/__tests__/fixtures/github-repo.json b/__tests__/.fixtures/github-repo.json similarity index 100% rename from __tests__/fixtures/github-repo.json rename to __tests__/.fixtures/github-repo.json diff --git a/__tests__/fixtures/hello-bake.hcl b/__tests__/.fixtures/hello-bake.hcl similarity index 100% rename from __tests__/fixtures/hello-bake.hcl rename to __tests__/.fixtures/hello-bake.hcl diff --git a/__tests__/fixtures/hello-err.Dockerfile b/__tests__/.fixtures/hello-err.Dockerfile similarity index 100% rename from __tests__/fixtures/hello-err.Dockerfile rename to __tests__/.fixtures/hello-err.Dockerfile diff --git a/__tests__/fixtures/hello.Dockerfile b/__tests__/.fixtures/hello.Dockerfile similarity index 100% rename from __tests__/fixtures/hello.Dockerfile rename to __tests__/.fixtures/hello.Dockerfile diff --git a/__tests__/fixtures/inspect1.txt b/__tests__/.fixtures/inspect1.txt similarity index 100% rename from __tests__/fixtures/inspect1.txt rename to __tests__/.fixtures/inspect1.txt diff --git a/__tests__/fixtures/inspect10.txt b/__tests__/.fixtures/inspect10.txt similarity index 100% rename from __tests__/fixtures/inspect10.txt rename to __tests__/.fixtures/inspect10.txt diff --git a/__tests__/fixtures/inspect11.txt b/__tests__/.fixtures/inspect11.txt similarity index 100% rename from __tests__/fixtures/inspect11.txt rename to __tests__/.fixtures/inspect11.txt diff --git a/__tests__/fixtures/inspect2.txt b/__tests__/.fixtures/inspect2.txt similarity index 100% rename from __tests__/fixtures/inspect2.txt rename to __tests__/.fixtures/inspect2.txt diff --git a/__tests__/fixtures/inspect3.txt b/__tests__/.fixtures/inspect3.txt similarity index 100% rename from __tests__/fixtures/inspect3.txt rename to __tests__/.fixtures/inspect3.txt diff --git a/__tests__/fixtures/inspect4.txt b/__tests__/.fixtures/inspect4.txt similarity index 100% rename from __tests__/fixtures/inspect4.txt rename to __tests__/.fixtures/inspect4.txt diff --git a/__tests__/fixtures/inspect5.txt b/__tests__/.fixtures/inspect5.txt similarity index 100% rename from __tests__/fixtures/inspect5.txt rename to __tests__/.fixtures/inspect5.txt diff --git a/__tests__/fixtures/inspect6.txt b/__tests__/.fixtures/inspect6.txt similarity index 100% rename from __tests__/fixtures/inspect6.txt rename to __tests__/.fixtures/inspect6.txt diff --git a/__tests__/fixtures/inspect7.txt b/__tests__/.fixtures/inspect7.txt similarity index 100% rename from __tests__/fixtures/inspect7.txt rename to __tests__/.fixtures/inspect7.txt diff --git a/__tests__/fixtures/inspect8.txt b/__tests__/.fixtures/inspect8.txt similarity index 100% rename from __tests__/fixtures/inspect8.txt rename to __tests__/.fixtures/inspect8.txt diff --git a/__tests__/fixtures/inspect9.txt b/__tests__/.fixtures/inspect9.txt similarity index 100% rename from __tests__/fixtures/inspect9.txt rename to __tests__/.fixtures/inspect9.txt diff --git a/__tests__/fixtures/lint-other.Dockerfile b/__tests__/.fixtures/lint-other.Dockerfile similarity index 100% rename from __tests__/fixtures/lint-other.Dockerfile rename to __tests__/.fixtures/lint-other.Dockerfile diff --git a/__tests__/fixtures/lint.Dockerfile b/__tests__/.fixtures/lint.Dockerfile similarity index 100% rename from __tests__/fixtures/lint.Dockerfile rename to __tests__/.fixtures/lint.Dockerfile diff --git a/__tests__/fixtures/lint.hcl b/__tests__/.fixtures/lint.hcl similarity index 100% rename from __tests__/fixtures/lint.hcl rename to __tests__/.fixtures/lint.hcl diff --git a/__tests__/fixtures/metadata-bake.json b/__tests__/.fixtures/metadata-bake.json similarity index 100% rename from __tests__/fixtures/metadata-bake.json rename to __tests__/.fixtures/metadata-bake.json diff --git a/__tests__/fixtures/metadata-build.json b/__tests__/.fixtures/metadata-build.json similarity index 100% rename from __tests__/fixtures/metadata-build.json rename to __tests__/.fixtures/metadata-build.json diff --git a/__tests__/fixtures/oci-archive/crazy-max~docker-alpine-s6~II9A63.dockerbuild b/__tests__/.fixtures/oci-archive/crazy-max~docker-alpine-s6~II9A63.dockerbuild similarity index 100% rename from __tests__/fixtures/oci-archive/crazy-max~docker-alpine-s6~II9A63.dockerbuild rename to __tests__/.fixtures/oci-archive/crazy-max~docker-alpine-s6~II9A63.dockerbuild diff --git a/__tests__/fixtures/oci-archive/docker~test-docker-action~COIO50.dockerbuild b/__tests__/.fixtures/oci-archive/docker~test-docker-action~COIO50.dockerbuild similarity index 100% rename from __tests__/fixtures/oci-archive/docker~test-docker-action~COIO50.dockerbuild rename to __tests__/.fixtures/oci-archive/docker~test-docker-action~COIO50.dockerbuild diff --git a/__tests__/fixtures/oci-archive/docker~test-docker-action~SNHBPN+3.dockerbuild b/__tests__/.fixtures/oci-archive/docker~test-docker-action~SNHBPN+3.dockerbuild similarity index 100% rename from __tests__/fixtures/oci-archive/docker~test-docker-action~SNHBPN+3.dockerbuild rename to __tests__/.fixtures/oci-archive/docker~test-docker-action~SNHBPN+3.dockerbuild diff --git a/__tests__/fixtures/oci-archive/docker~test-docker-action~TYO4JJ+15.dockerbuild b/__tests__/.fixtures/oci-archive/docker~test-docker-action~TYO4JJ+15.dockerbuild similarity index 100% rename from __tests__/fixtures/oci-archive/docker~test-docker-action~TYO4JJ+15.dockerbuild rename to __tests__/.fixtures/oci-archive/docker~test-docker-action~TYO4JJ+15.dockerbuild diff --git a/__tests__/fixtures/oci-archive/hello-oci-gzip.tar b/__tests__/.fixtures/oci-archive/hello-oci-gzip.tar similarity index 100% rename from __tests__/fixtures/oci-archive/hello-oci-gzip.tar rename to __tests__/.fixtures/oci-archive/hello-oci-gzip.tar diff --git a/__tests__/fixtures/oci-archive/hello-oci-multiplatform-gzip.tar b/__tests__/.fixtures/oci-archive/hello-oci-multiplatform-gzip.tar similarity index 100% rename from __tests__/fixtures/oci-archive/hello-oci-multiplatform-gzip.tar rename to __tests__/.fixtures/oci-archive/hello-oci-multiplatform-gzip.tar diff --git a/__tests__/fixtures/oci-archive/hello-oci-uncompressed.tar b/__tests__/.fixtures/oci-archive/hello-oci-uncompressed.tar similarity index 100% rename from __tests__/fixtures/oci-archive/hello-oci-uncompressed.tar rename to __tests__/.fixtures/oci-archive/hello-oci-uncompressed.tar diff --git a/__tests__/fixtures/oci-archive/hello-oci-zstd.tar b/__tests__/.fixtures/oci-archive/hello-oci-zstd.tar similarity index 100% rename from __tests__/fixtures/oci-archive/hello-oci-zstd.tar rename to __tests__/.fixtures/oci-archive/hello-oci-zstd.tar diff --git a/__tests__/fixtures/oci-archive/moby~buildkit~LWDOW6.dockerbuild b/__tests__/.fixtures/oci-archive/moby~buildkit~LWDOW6.dockerbuild similarity index 100% rename from __tests__/fixtures/oci-archive/moby~buildkit~LWDOW6.dockerbuild rename to __tests__/.fixtures/oci-archive/moby~buildkit~LWDOW6.dockerbuild diff --git a/__tests__/fixtures/pgp.txt b/__tests__/.fixtures/pgp.txt similarity index 100% rename from __tests__/fixtures/pgp.txt rename to __tests__/.fixtures/pgp.txt diff --git a/__tests__/fixtures/runtimeToken.txt b/__tests__/.fixtures/runtimeToken.txt similarity index 100% rename from __tests__/fixtures/runtimeToken.txt rename to __tests__/.fixtures/runtimeToken.txt diff --git a/__tests__/fixtures/secret.txt b/__tests__/.fixtures/secret.txt similarity index 100% rename from __tests__/fixtures/secret.txt rename to __tests__/.fixtures/secret.txt diff --git a/__tests__/buildkit/config.test.ts b/__tests__/buildkit/config.test.ts index bf345ff..513ce15 100644 --- a/__tests__/buildkit/config.test.ts +++ b/__tests__/buildkit/config.test.ts @@ -15,22 +15,20 @@ */ import {describe, expect, jest, test, afterEach} from '@jest/globals'; -import * as fs from 'fs'; -import * as path from 'path'; +import fs from 'fs'; +import os from 'os'; +import path from 'path'; import * as rimraf from 'rimraf'; import {BuildKit} from '../../src/buildkit/buildkit'; import {Context} from '../../src/context'; -const fixturesDir = path.join(__dirname, '..', 'fixtures'); -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildkit-config-jest'); +const fixturesDir = path.join(__dirname, '..', '.fixtures'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildkit-config-')); const tmpName = path.join(tmpDir, '.tmpname-jest'); jest.spyOn(Context, 'tmpDir').mockImplementation((): string => { - if (!fs.existsSync(tmpDir)) { - fs.mkdirSync(tmpDir, {recursive: true}); - } + fs.mkdirSync(tmpDir, {recursive: true}); return tmpDir; }); diff --git a/__tests__/buildx/bake.test.itg.ts b/__tests__/buildx/bake.test.itg.ts index f4499f2..0f0f955 100644 --- a/__tests__/buildx/bake.test.itg.ts +++ b/__tests__/buildx/bake.test.itg.ts @@ -21,7 +21,7 @@ import * as path from 'path'; import {Bake} from '../../src/buildx/bake'; import {BakeDefinition} from '../../src/types/buildx/bake'; -const fixturesDir = path.join(__dirname, '..', 'fixtures'); +const fixturesDir = path.join(__dirname, '..', '.fixtures'); const maybe = !process.env.GITHUB_ACTIONS || (process.env.GITHUB_ACTIONS === 'true' && process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) ? describe : describe.skip; diff --git a/__tests__/buildx/bake.test.ts b/__tests__/buildx/bake.test.ts index 47f22d3..1bb0ff1 100644 --- a/__tests__/buildx/bake.test.ts +++ b/__tests__/buildx/bake.test.ts @@ -15,8 +15,9 @@ */ import {afterEach, describe, expect, it, jest, test} from '@jest/globals'; -import * as fs from 'fs'; -import * as path from 'path'; +import fs from 'fs'; +import os from 'os'; +import path from 'path'; import * as rimraf from 'rimraf'; import {Bake} from '../../src/buildx/bake'; @@ -26,16 +27,13 @@ import {ExecOptions} from '@actions/exec'; import {BakeDefinition} from '../../src/types/buildx/bake'; import {BuildMetadata} from '../../src/types/buildx/build'; -const fixturesDir = path.join(__dirname, '..', 'fixtures'); -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-bake-jest'); +const fixturesDir = path.join(__dirname, '..', '.fixtures'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-bake-')); const tmpName = path.join(tmpDir, '.tmpname-jest'); const metadata = JSON.parse(fs.readFileSync(path.join(fixturesDir, 'metadata-bake.json'), 'utf-8')); jest.spyOn(Context, 'tmpDir').mockImplementation((): string => { - if (!fs.existsSync(tmpDir)) { - fs.mkdirSync(tmpDir, {recursive: true}); - } + fs.mkdirSync(tmpDir, {recursive: true}); return tmpDir; }); diff --git a/__tests__/buildx/build.test.ts b/__tests__/buildx/build.test.ts index f7bc83c..6659366 100644 --- a/__tests__/buildx/build.test.ts +++ b/__tests__/buildx/build.test.ts @@ -15,23 +15,21 @@ */ import {afterEach, beforeEach, describe, expect, it, jest, test} from '@jest/globals'; -import * as fs from 'fs'; -import * as path from 'path'; +import fs from 'fs'; +import os from 'os'; +import path from 'path'; import * as rimraf from 'rimraf'; import {Context} from '../../src/context'; import {Build} from '../../src/buildx/build'; -const fixturesDir = path.join(__dirname, '..', 'fixtures'); -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-build-jest'); +const fixturesDir = path.join(__dirname, '..', '.fixtures'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-build-')); const tmpName = path.join(tmpDir, '.tmpname-jest'); const metadata = JSON.parse(fs.readFileSync(path.join(fixturesDir, 'metadata-build.json'), 'utf-8')); jest.spyOn(Context, 'tmpDir').mockImplementation((): string => { - if (!fs.existsSync(tmpDir)) { - fs.mkdirSync(tmpDir, {recursive: true}); - } + fs.mkdirSync(tmpDir, {recursive: true}); return tmpDir; }); diff --git a/__tests__/buildx/builder.test.ts b/__tests__/buildx/builder.test.ts index dd060f5..f19ef9f 100644 --- a/__tests__/buildx/builder.test.ts +++ b/__tests__/buildx/builder.test.ts @@ -23,7 +23,7 @@ import {Exec} from '../../src/exec'; import {BuilderInfo} from '../../src/types/buildx/builder'; -const fixturesDir = path.join(__dirname, '..', 'fixtures'); +const fixturesDir = path.join(__dirname, '..', '.fixtures'); jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise => { return { diff --git a/__tests__/buildx/buildx.test.itg.ts b/__tests__/buildx/buildx.test.itg.ts index cf7bcdc..f4b22a9 100644 --- a/__tests__/buildx/buildx.test.itg.ts +++ b/__tests__/buildx/buildx.test.itg.ts @@ -15,8 +15,9 @@ */ import {describe, expect, it} from '@jest/globals'; -import * as fs from 'fs'; -import * as path from 'path'; +import fs from 'fs'; +import os from 'os'; +import path from 'path'; import * as core from '@actions/core'; import {Buildx} from '../../src/buildx/buildx'; @@ -24,10 +25,8 @@ import {Build} from '../../src/buildx/build'; import {Bake} from '../../src/buildx/bake'; import {Exec} from '../../src/exec'; -const fixturesDir = path.join(__dirname, '..', 'fixtures'); - -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest'); +const fixturesDir = path.join(__dirname, '..', '.fixtures'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-buildx-itg-')); const maybe = !process.env.GITHUB_ACTIONS || (process.env.GITHUB_ACTIONS === 'true' && process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) ? describe : describe.skip; diff --git a/__tests__/buildx/buildx.test.ts b/__tests__/buildx/buildx.test.ts index a876780..3fa41a4 100644 --- a/__tests__/buildx/buildx.test.ts +++ b/__tests__/buildx/buildx.test.ts @@ -15,8 +15,9 @@ */ import {describe, expect, it, jest, test, beforeEach, afterEach} from '@jest/globals'; -import * as fs from 'fs'; -import * as path from 'path'; +import fs from 'fs'; +import os from 'os'; +import path from 'path'; import * as rimraf from 'rimraf'; import * as semver from 'semver'; @@ -26,15 +27,12 @@ import {Exec} from '../../src/exec'; import {Cert, LocalState} from '../../src/types/buildx/buildx'; -const fixturesDir = path.join(__dirname, '..', 'fixtures'); -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest'); +const fixturesDir = path.join(__dirname, '..', '.fixtures'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-buildx-')); const tmpName = path.join(tmpDir, '.tmpname-jest'); jest.spyOn(Context, 'tmpDir').mockImplementation((): string => { - if (!fs.existsSync(tmpDir)) { - fs.mkdirSync(tmpDir, {recursive: true}); - } + fs.mkdirSync(tmpDir, {recursive: true}); return tmpDir; }); diff --git a/__tests__/buildx/history.test.itg.ts b/__tests__/buildx/history.test.itg.ts index efcf1e8..52e4895 100644 --- a/__tests__/buildx/history.test.itg.ts +++ b/__tests__/buildx/history.test.itg.ts @@ -15,8 +15,9 @@ */ import {afterEach, beforeEach, describe, expect, it, jest, test} from '@jest/globals'; -import * as fs from 'fs'; -import * as path from 'path'; +import fs from 'fs'; +import os from 'os'; +import path from 'path'; import {Buildx} from '../../src/buildx/buildx'; import {Bake} from '../../src/buildx/bake'; @@ -24,10 +25,8 @@ import {Build} from '../../src/buildx/build'; import {History} from '../../src/buildx/history'; import {Exec} from '../../src/exec'; -const fixturesDir = path.join(__dirname, '..', 'fixtures'); - -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-history-jest'); +const fixturesDir = path.join(__dirname, '..', '.fixtures'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-history-itg-')); const maybe = !process.env.GITHUB_ACTIONS || (process.env.GITHUB_ACTIONS === 'true' && process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) ? describe : describe.skip; diff --git a/__tests__/buildx/install.test.ts b/__tests__/buildx/install.test.ts index 92ae0b3..ed5b358 100644 --- a/__tests__/buildx/install.test.ts +++ b/__tests__/buildx/install.test.ts @@ -15,15 +15,15 @@ */ import {describe, expect, it, jest, test, afterEach} from '@jest/globals'; -import * as fs from 'fs'; -import * as path from 'path'; +import fs from 'fs'; +import os from 'os'; +import path from 'path'; import * as rimraf from 'rimraf'; import osm = require('os'); import {Install} from '../../src/buildx/install'; -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'buildx-install-')); afterEach(function () { rimraf.sync(tmpDir); diff --git a/__tests__/cache.test.itg.ts b/__tests__/cache.test.itg.ts index ad295f7..a32d4c6 100644 --- a/__tests__/cache.test.itg.ts +++ b/__tests__/cache.test.itg.ts @@ -14,15 +14,15 @@ * limitations under the License. */ -import path from 'path'; import {describe, expect, it} from '@jest/globals'; +import fs from 'fs'; +import os from 'os'; +import path from 'path'; import {Cache} from '../src/cache'; -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'cache-jest'); - -const fixturesDir = path.join(__dirname, 'fixtures'); +const fixturesDir = path.join(__dirname, '.fixtures'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'cache-itg-')); describe('cache', () => { it('github-repo', async () => { diff --git a/__tests__/context.test.ts b/__tests__/context.test.ts index 325655c..0f97583 100644 --- a/__tests__/context.test.ts +++ b/__tests__/context.test.ts @@ -14,21 +14,19 @@ * limitations under the License. */ -import * as fs from 'fs'; -import * as path from 'path'; -import * as rimraf from 'rimraf'; import {describe, expect, jest, it, afterEach} from '@jest/globals'; +import fs from 'fs'; +import os from 'os'; +import path from 'path'; +import * as rimraf from 'rimraf'; import {Context} from '../src/context'; -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'context-jest'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'context-')); const tmpName = path.join(tmpDir, '.tmpname-jest'); jest.spyOn(Context, 'tmpDir').mockImplementation((): string => { - if (!fs.existsSync(tmpDir)) { - fs.mkdirSync(tmpDir, {recursive: true}); - } + fs.mkdirSync(tmpDir, {recursive: true}); return tmpDir; }); diff --git a/__tests__/docker/docker.test.ts b/__tests__/docker/docker.test.ts index ea4f78f..c0bd65a 100644 --- a/__tests__/docker/docker.test.ts +++ b/__tests__/docker/docker.test.ts @@ -15,7 +15,8 @@ */ import {afterEach, beforeEach, describe, expect, it, jest} from '@jest/globals'; -import * as fs from 'fs'; +import fs from 'fs'; +import os from 'os'; import path from 'path'; import * as io from '@actions/io'; import osm = require('os'); @@ -25,10 +26,8 @@ import {Docker} from '../../src/docker/docker'; import {ConfigFile} from '../../src/types/docker/docker'; -const fixturesDir = path.join(__dirname, '..', 'fixtures'); - -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-jest'); +const fixturesDir = path.join(__dirname, '..', '.fixtures'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-docker-')); afterEach(function () { rimraf.sync(tmpDir); diff --git a/__tests__/docker/install.test.itg.ts b/__tests__/docker/install.test.itg.ts index c55f43a..679fa85 100644 --- a/__tests__/docker/install.test.itg.ts +++ b/__tests__/docker/install.test.itg.ts @@ -14,15 +14,16 @@ * limitations under the License. */ -import path from 'path'; import {jest, describe, expect, test, beforeEach, afterEach} from '@jest/globals'; +import fs from 'fs'; +import os from 'os'; +import path from 'path'; import {Install} from '../../src/docker/install'; import {Docker} from '../../src/docker/docker'; import {Exec} from '../../src/exec'; -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-install-jest'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-itg-')); describe('install', () => { const originalEnv = process.env; diff --git a/__tests__/docker/install.test.ts b/__tests__/docker/install.test.ts index ab92131..80ecc29 100644 --- a/__tests__/docker/install.test.ts +++ b/__tests__/docker/install.test.ts @@ -15,15 +15,15 @@ */ import {describe, expect, jest, test, beforeEach, afterEach, it} from '@jest/globals'; -import * as fs from 'fs'; -import * as path from 'path'; +import fs from 'fs'; +import os from 'os'; +import path from 'path'; import * as rimraf from 'rimraf'; import osm = require('os'); import {Install} from '../../src/docker/install'; -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-install-jest'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-')); afterEach(function () { rimraf.sync(tmpDir); diff --git a/__tests__/dockerhub.test.ts b/__tests__/dockerhub.test.ts index 971cfb5..50ab3c2 100644 --- a/__tests__/dockerhub.test.ts +++ b/__tests__/dockerhub.test.ts @@ -21,9 +21,9 @@ import * as path from 'path'; import {DockerHub} from '../src/dockerhub'; import {RepositoryResponse, RepositoryTagsResponse} from '../src/types/dockerhub'; -import repoInfoFixture from './fixtures/dockerhub-repoinfo.json'; -import repoTagsFixture from './fixtures/dockerhub-repotags.json'; -import repoAllTagsFixture from './fixtures/dockerhub-repoalltags.json'; +import repoInfoFixture from './.fixtures/dockerhub-repoinfo.json'; +import repoTagsFixture from './.fixtures/dockerhub-repotags.json'; +import repoAllTagsFixture from './.fixtures/dockerhub-repoalltags.json'; describe('getRepository', () => { it('returns repo info', async () => { diff --git a/__tests__/github.test.itg.ts b/__tests__/github.test.itg.ts index b720ece..7a3a718 100644 --- a/__tests__/github.test.itg.ts +++ b/__tests__/github.test.itg.ts @@ -16,7 +16,8 @@ import {describe, expect, it, test} from '@jest/globals'; import fs from 'fs'; -import * as path from 'path'; +import os from 'os'; +import path from 'path'; import {Buildx} from '../src/buildx/buildx'; import {Bake} from '../src/buildx/bake'; @@ -25,10 +26,8 @@ import {Exec} from '../src/exec'; import {GitHub} from '../src/github'; import {History} from '../src/buildx/history'; -const fixturesDir = path.join(__dirname, 'fixtures'); - -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'github-jest'); +const fixturesDir = path.join(__dirname, '.fixtures'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'github-itg-')); const maybe = !process.env.GITHUB_ACTIONS || (process.env.GITHUB_ACTIONS === 'true' && process.env.ImageOS && process.env.ImageOS.startsWith('ubuntu')) ? describe : describe.skip; diff --git a/__tests__/github.test.ts b/__tests__/github.test.ts index 54c211a..4f78cd9 100644 --- a/__tests__/github.test.ts +++ b/__tests__/github.test.ts @@ -22,7 +22,7 @@ import * as core from '@actions/core'; import {GitHub} from '../src/github'; import {GitHubRepo} from '../src/types/github'; -import repoFixture from './fixtures/github-repo.json'; +import repoFixture from './.fixtures/github-repo.json'; jest.spyOn(GitHub.prototype, 'repoData').mockImplementation((): Promise => { return >(repoFixture as unknown); }); @@ -123,7 +123,7 @@ describe('actionsRuntimeToken', () => { }); it('fixture', async () => { process.env.ACTIONS_RUNTIME_TOKEN = fs - .readFileSync(path.join(__dirname, 'fixtures', 'runtimeToken.txt')) + .readFileSync(path.join(__dirname, '.fixtures', 'runtimeToken.txt')) .toString() .trim(); const runtimeToken = GitHub.actionsRuntimeToken; @@ -154,7 +154,7 @@ describe('printActionsRuntimeTokenACs', () => { it('refs/heads/master', async () => { const infoSpy = jest.spyOn(core, 'info'); process.env.ACTIONS_RUNTIME_TOKEN = fs - .readFileSync(path.join(__dirname, 'fixtures', 'runtimeToken.txt')) + .readFileSync(path.join(__dirname, '.fixtures', 'runtimeToken.txt')) .toString() .trim(); await GitHub.printActionsRuntimeTokenACs(); diff --git a/__tests__/oci/oci.test.ts b/__tests__/oci/oci.test.ts index 54dadf5..803db12 100644 --- a/__tests__/oci/oci.test.ts +++ b/__tests__/oci/oci.test.ts @@ -15,16 +15,15 @@ */ import {afterEach, describe, expect, test} from '@jest/globals'; -import * as fs from 'fs'; +import fs from 'fs'; +import os from 'os'; import path from 'path'; import * as rimraf from 'rimraf'; import {OCI} from '../../src/oci/oci'; -const fixturesDir = path.join(__dirname, '..', 'fixtures'); - -// prettier-ignore -const tmpDir = path.join(process.env.TEMP || '/tmp', 'docker-jest'); +const fixturesDir = path.join(__dirname, '..', '.fixtures'); +const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'oci-oci-')); afterEach(function () { rimraf.sync(tmpDir); diff --git a/__tests__/util.test.ts b/__tests__/util.test.ts index 2a733d9..ccd083f 100644 --- a/__tests__/util.test.ts +++ b/__tests__/util.test.ts @@ -165,7 +165,7 @@ FOO=bar` }); it('large multiline values', async () => { - const pgp = fs.readFileSync(path.join(__dirname, 'fixtures', 'pgp.txt'), {encoding: 'utf-8'}); + const pgp = fs.readFileSync(path.join(__dirname, '.fixtures', 'pgp.txt'), {encoding: 'utf-8'}); setInput( 'secrets', `"GPG_KEY=${pgp}"