-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: source archive builder #3587
Open
laurentsimon
wants to merge
9
commits into
slsa-framework:main
Choose a base branch
from
laurentsimon:feat/archive-builder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f7eaf71
update
laurentsimon 1c33fab
update
laurentsimon 41e2f32
update
laurentsimon afa21bb
missing files
laurentsimon 3a3449e
update
laurentsimon 5320c1b
update
laurentsimon 643d4d6
update
laurentsimon e8afc25
update
laurentsimon 50ab229
update
laurentsimon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright 2023 SLSA 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. | ||
|
||
name: SLSA Source archive builder | ||
|
||
permissions: {} | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
formats: | ||
description: > | ||
A list of archive formats to generate. Supported: "zip" and "tar.gz". | ||
Each format must be separated by a space or on a new line. | ||
|
||
Example: "zip tar.gz" | ||
required: true | ||
type: string | ||
upload-assets: | ||
description: > | ||
If true, provenance is uploaded to a GitHub release for new tags. | ||
The only value supported is 'true'. The workflow will fail if set to 'false'. | ||
required: false | ||
type: boolean | ||
default: true | ||
# NOTE: the additional inputs below are to support additional | ||
# functionality of the workflow. | ||
rekor-log-public: | ||
description: "Allow publication of your repository name on the public Rekor log" | ||
required: false | ||
type: boolean | ||
default: false | ||
|
||
jobs: | ||
slsa-setup: | ||
permissions: | ||
id-token: write # For token creation. | ||
outputs: | ||
slsa-token: ${{ steps.generate.outputs.slsa-token }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Generate the token | ||
id: generate | ||
uses: slsa-framework/slsa-github-generator/actions/delegator/setup-generic@main | ||
with: | ||
slsa-workflow-recipient: "delegator_generic_slsa3.yml" | ||
slsa-rekor-log-public: ${{ inputs.rekor-log-public }} | ||
slsa-runner-label: "ubuntu-latest" | ||
slsa-build-action-path: "./internal/builders/archive" | ||
slsa-workflow-inputs: ${{ toJson(inputs) }} | ||
|
||
slsa-run: | ||
needs: [slsa-setup] | ||
permissions: | ||
id-token: write # For signing. | ||
contents: read # For repo checkout of private repos. | ||
actions: read # For getting workflow run on private repos. | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/delegator_generic_slsa3.yml@main | ||
with: | ||
slsa-token: ${{ needs.slsa-setup.outputs.slsa-token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright 2023 SLSA 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. | ||
|
||
SHELL := /bin/bash | ||
ACTION_NAME = $(shell basename "$$(pwd)") | ||
|
||
.PHONY: help | ||
help: ## Shows all targets and help from the Makefile (this message). | ||
@echo "$(ACTION_NAME) Makefile" | ||
@echo "Usage: make [COMMAND]" | ||
@echo "" | ||
@grep --no-filename -E '^([/a-z.A-Z0-9_%-]+:.*?|)##' $(MAKEFILE_LIST) | \ | ||
awk 'BEGIN {FS = "(:.*?|)## ?"}; { \ | ||
if (length($$1) > 0) { \ | ||
printf " \033[36m%-20s\033[0m %s\n", $$1, $$2; \ | ||
} else { \ | ||
if (length($$2) > 0) { \ | ||
printf "%s\n", $$2; \ | ||
} \ | ||
} \ | ||
}' | ||
|
||
node_modules/.installed: package.json package-lock.json | ||
npm ci | ||
touch node_modules/.installed | ||
|
||
.PHONY: action | ||
action: node_modules/.installed ## Builds the action. | ||
npm run build | ||
|
||
.PHONY: package | ||
package: action ## Builds the distribution package. | ||
npm run package | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf dist lib node_modules | ||
|
||
## Tools | ||
##################################################################### | ||
|
||
.PHONY: format | ||
format: node_modules/.installed ## Formats code. | ||
npm run format | ||
|
||
## Testing | ||
##################################################################### | ||
|
||
.PHONY: unit-test | ||
unit-test: node_modules/.installed ## Runs all unit tests. | ||
npm run test | ||
|
||
.PHONY: lint | ||
lint: node_modules/.installed ## Runs eslint. | ||
npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// Copyright 2023 SLSA 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. | ||
|
||
/** | ||
* @fileoverview Tests for inputs.ts | ||
*/ | ||
|
||
import * as inputs from "../src/inputs"; | ||
|
||
describe("parseFormats", () => { | ||
it("empty value", async () => { | ||
const value = ""; | ||
expect(() => { | ||
const formats = inputs.parseFormats(value); | ||
}).toThrow(); | ||
}); | ||
|
||
it("space value", async () => { | ||
const value = " "; | ||
expect(() => { | ||
const formats = inputs.parseFormats(value); | ||
}).toThrow(); | ||
}); | ||
|
||
it("eol value", async () => { | ||
const value = ` | ||
`; | ||
expect(() => { | ||
const formats = inputs.parseFormats(value); | ||
}).toThrow(); | ||
}); | ||
|
||
it("eol + space value", async () => { | ||
const value = ` | ||
|
||
`; | ||
expect(() => { | ||
const formats = inputs.parseFormats(value); | ||
}).toThrow(); | ||
}); | ||
|
||
it("one line one format", async () => { | ||
const value = "zip"; | ||
const formats = inputs.parseFormats(value); | ||
expect(formats).toEqual(["zip"]); | ||
}); | ||
|
||
it("one line one format with space", async () => { | ||
const value = " zip "; | ||
const formats = inputs.parseFormats(value); | ||
expect(formats).toEqual(["zip"]); | ||
}); | ||
|
||
it("one line two format", async () => { | ||
const value = "zip tar.gz"; | ||
const formats = inputs.parseFormats(value); | ||
expect(formats).toEqual(["zip", "tar.gz"]); | ||
}); | ||
|
||
it("one line two format with space", async () => { | ||
const value = " zip tar.gz "; | ||
const formats = inputs.parseFormats(value); | ||
expect(formats).toEqual(["zip", "tar.gz"]); | ||
}); | ||
|
||
it("two line two format with tab", async () => { | ||
const value = `zip | ||
tar.gz`; | ||
const formats = inputs.parseFormats(value); | ||
expect(formats).toEqual(["zip", "tar.gz"]); | ||
}); | ||
|
||
it("two line two format with tab and space", async () => { | ||
const value = ` zip | ||
tar.gz `; | ||
const formats = inputs.parseFormats(value); | ||
expect(formats).toEqual(["zip", "tar.gz"]); | ||
}); | ||
}); | ||
|
||
describe("formatsToAPI", () => { | ||
it("empty formats", async () => { | ||
const formats: string[] = []; | ||
expect(() => { | ||
const actual = inputs.formatsToAPI(formats); | ||
}).toThrow(); | ||
}); | ||
|
||
it("two valid formats", async () => { | ||
const formats = ["zip", "tar.gz"]; | ||
const actual = inputs.formatsToAPI(formats); | ||
expect(actual).toEqual(["zipball", "tarball"]); | ||
}); | ||
|
||
it("tarball format", async () => { | ||
const formats = ["tar.gz"]; | ||
const actual = inputs.formatsToAPI(formats); | ||
expect(actual).toEqual(["tarball"]); | ||
}); | ||
|
||
it("zip format", async () => { | ||
const formats = ["zip"]; | ||
const actual = inputs.formatsToAPI(formats); | ||
expect(actual).toEqual(["zipball"]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright 2024 SLSA 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. | ||
|
||
name: SLSA3 Builder internal wrapper | ||
description: SLSA3 Builder internal wrapper | ||
|
||
inputs: | ||
slsa-workflow-inputs: | ||
description: "All the inputs formatted as a JSON map" | ||
required: true | ||
|
||
slsa-layout-file: | ||
description: "Location to store the layout content" | ||
required: true | ||
|
||
# Unused secret inputs. | ||
slsa-workflow-secret1: {} | ||
slsa-workflow-secret2: {} | ||
slsa-workflow-secret3: {} | ||
slsa-workflow-secret4: {} | ||
slsa-workflow-secret5: {} | ||
slsa-workflow-secret6: {} | ||
slsa-workflow-secret7: {} | ||
slsa-workflow-secret8: {} | ||
slsa-workflow-secret9: {} | ||
slsa-workflow-secret10: {} | ||
slsa-workflow-secret11: {} | ||
slsa-workflow-secret12: {} | ||
slsa-workflow-secret13: {} | ||
slsa-workflow-secret14: {} | ||
slsa-workflow-secret15: {} | ||
|
||
runs: | ||
using: "node20" | ||
main: "dist/index.js" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have this option at all? Can't you hard code the value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking in terms of backward compatibility, eg if we ever want to support non-release archive generation. This would require folks being able to set whether they want to upload or not, for example. By default it could be that it does not upload, like in other workflows we have. Let me think a bit more, I'm less convinced than I was yesterday :)