diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0a3b49f..446d742 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,13 @@ on: jobs: validate: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + target: + - lint + - vendor-validate + - license-validate steps: - name: Checkout @@ -19,7 +26,7 @@ jobs: name: Validate uses: docker/bake-action@v2 with: - targets: validate + targets: ${{ matrix.target }} test: runs-on: ubuntu-latest diff --git a/__mocks__/@actions/github.ts b/__mocks__/@actions/github.ts index 578a3de..8a0e946 100644 --- a/__mocks__/@actions/github.ts +++ b/__mocks__/@actions/github.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {jest} from '@jest/globals'; export const context = { diff --git a/__tests__/builder.test.ts b/__tests__/builder.test.ts index 3d0ae28..4999243 100644 --- a/__tests__/builder.test.ts +++ b/__tests__/builder.test.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {beforeEach, describe, expect, it, jest, test} from '@jest/globals'; import * as fs from 'fs'; import * as path from 'path'; diff --git a/__tests__/buildkit.test.ts b/__tests__/buildkit.test.ts index c0f69a9..7266693 100644 --- a/__tests__/buildkit.test.ts +++ b/__tests__/buildkit.test.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {describe, expect, it, jest, test, beforeEach, afterEach} from '@jest/globals'; import * as fs from 'fs'; import * as path from 'path'; diff --git a/__tests__/buildx.test.ts b/__tests__/buildx.test.ts index 78ea338..6e2243b 100644 --- a/__tests__/buildx.test.ts +++ b/__tests__/buildx.test.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {describe, expect, it, jest, test, beforeEach, afterEach} from '@jest/globals'; import * as fs from 'fs'; import * as path from 'path'; diff --git a/__tests__/context.test.ts b/__tests__/context.test.ts index 74d7c19..af4980c 100644 --- a/__tests__/context.test.ts +++ b/__tests__/context.test.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import fs from 'fs'; import path from 'path'; import rimraf from 'rimraf'; diff --git a/__tests__/docker.test.ts b/__tests__/docker.test.ts index 427d369..1ee1dfd 100644 --- a/__tests__/docker.test.ts +++ b/__tests__/docker.test.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {beforeEach, describe, expect, it, jest} from '@jest/globals'; import * as exec from '@actions/exec'; diff --git a/__tests__/git.test.ts b/__tests__/git.test.ts index a4de324..c3d8712 100644 --- a/__tests__/git.test.ts +++ b/__tests__/git.test.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {beforeEach, describe, expect, it, jest} from '@jest/globals'; import {Git} from '../src/git'; diff --git a/__tests__/github.test.ts b/__tests__/github.test.ts index e24ad32..7754b5a 100644 --- a/__tests__/github.test.ts +++ b/__tests__/github.test.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {describe, expect, jest, it, beforeEach, afterEach} from '@jest/globals'; import * as fs from 'fs'; import * as path from 'path'; diff --git a/__tests__/util.test.ts b/__tests__/util.test.ts index 8d9079e..87adffd 100644 --- a/__tests__/util.test.ts +++ b/__tests__/util.test.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {beforeEach, describe, expect, it, jest, test} from '@jest/globals'; import * as fs from 'fs'; import * as path from 'path'; diff --git a/dev.Dockerfile b/dev.Dockerfile index 581bdf1..6231f4f 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -1,5 +1,19 @@ # syntax=docker/dockerfile:1 +# Copyright 2023 actions-toolkit authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + ARG NODE_VERSION=16 ARG DOCKER_VERSION=20.10.22 ARG BUILDX_VERSION=0.10.0 diff --git a/docker-bake.hcl b/docker-bake.hcl index 265860f..bb4b1d0 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,3 +1,17 @@ +// Copyright 2023 actions-toolkit authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + group "default" { targets = ["build"] } @@ -7,7 +21,7 @@ group "pre-checkin" { } group "validate" { - targets = ["lint", "vendor-validate"] + targets = ["lint", "vendor-validate", "license-validate"] } target "build" { @@ -69,3 +83,15 @@ target "publish" { output = ["type=cacheonly"] secret = ["id=NODE_AUTH_TOKEN,env=NODE_AUTH_TOKEN"] } + +target "license-validate" { + dockerfile = "./hack/dockerfiles/license.Dockerfile" + target = "validate" + output = ["type=cacheonly"] +} + +target "license-update" { + dockerfile = "./hack/dockerfiles/license.Dockerfile" + target = "update" + output = ["."] +} diff --git a/hack/dockerfiles/license.Dockerfile b/hack/dockerfiles/license.Dockerfile new file mode 100644 index 0000000..9127510 --- /dev/null +++ b/hack/dockerfiles/license.Dockerfile @@ -0,0 +1,47 @@ +# syntax=docker/dockerfile:1 + +# Copyright 2023 actions-toolkit authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG LICENSE_HOLDER="actions-toolkit authors" +ARG LICENSE_TYPE="apache" +ARG LICENSE_FILES=".*\(Dockerfile\|Makefile\|\.js\|\.ts\|\.hcl\|\.sh\)" +ARG ADDLICENSE_VERSION="v1.0.0" + +FROM ghcr.io/google/addlicense:${ADDLICENSE_VERSION} AS addlicense + +FROM alpine:3.17 AS base +WORKDIR /src +RUN apk add --no-cache cpio findutils git + +FROM base AS set +ARG LICENSE_HOLDER +ARG LICENSE_TYPE +ARG LICENSE_FILES +RUN --mount=type=bind,target=.,rw \ + --mount=from=addlicense,source=/app/addlicense,target=/usr/bin/addlicense \ + find . -regex "${LICENSE_FILES}" -not -path "./.yarn/*" -not -path "./node_modules/*" | xargs addlicense -c "$LICENSE_HOLDER" -l "$LICENSE_TYPE" && \ + mkdir /out && \ + find . -regex "${LICENSE_FILES}" -not -path "./.yarn/*" -not -path "./node_modules/*" | cpio -pdm /out + +FROM scratch AS update +COPY --from=set /out / + +FROM base AS validate +ARG LICENSE_HOLDER +ARG LICENSE_TYPE +ARG LICENSE_FILES +RUN --mount=type=bind,target=. \ + --mount=from=addlicense,source=/app/addlicense,target=/usr/bin/addlicense \ + find . -regex "${LICENSE_FILES}" -not -path "./.yarn/*" -not -path "./node_modules/*" | xargs addlicense -check -c "$LICENSE_HOLDER" -l "$LICENSE_TYPE" diff --git a/jest.config.ts b/jest.config.ts index 36661f0..455328b 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + process.env = Object.assign({}, process.env, { GITHUB_REPOSITORY: 'docker/actions-toolkit', RUNNER_TEMP: '/tmp/github_runner', diff --git a/src/builder.ts b/src/builder.ts index 634a6e6..6240345 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import * as exec from '@actions/exec'; import {Buildx} from './buildx'; diff --git a/src/buildkit.ts b/src/buildkit.ts index 8186727..66cb270 100644 --- a/src/buildkit.ts +++ b/src/buildkit.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import fs from 'fs'; import * as core from '@actions/core'; import * as exec from '@actions/exec'; diff --git a/src/buildx.ts b/src/buildx.ts index 427d027..69d48c1 100644 --- a/src/buildx.ts +++ b/src/buildx.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import fs from 'fs'; import path from 'path'; import * as core from '@actions/core'; diff --git a/src/context.ts b/src/context.ts index 8854ef1..9c624b0 100644 --- a/src/context.ts +++ b/src/context.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import fs from 'fs'; import os from 'os'; import path from 'path'; diff --git a/src/docker.ts b/src/docker.ts index 6d77c8b..dca238d 100644 --- a/src/docker.ts +++ b/src/docker.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import * as exec from '@actions/exec'; export class Docker { diff --git a/src/git.ts b/src/git.ts index 217b037..459eae0 100644 --- a/src/git.ts +++ b/src/git.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import * as exec from '@actions/exec'; export class Git { diff --git a/src/github.ts b/src/github.ts index c84857b..9efc29f 100644 --- a/src/github.ts +++ b/src/github.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {GitHub as Octokit} from '@actions/github/lib/utils'; import * as github from '@actions/github'; import {components as OctoOpenApiTypes} from '@octokit/openapi-types'; diff --git a/src/toolkit.ts b/src/toolkit.ts index ef17a0a..168e7ae 100644 --- a/src/toolkit.ts +++ b/src/toolkit.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import {Context} from './context'; import {Buildx} from './buildx'; import {BuildKit} from './buildkit'; diff --git a/src/util.ts b/src/util.ts index 4a2a496..09fa0c9 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 actions-toolkit authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import * as core from '@actions/core'; import {parse} from 'csv-parse/sync';