From a500191144a3a400156feeaffbeb647383529be7 Mon Sep 17 00:00:00 2001 From: Jon Seager Date: Tue, 5 Dec 2023 17:44:05 +0000 Subject: [PATCH] fix: specify snapcraft-project-root instead of snapcraft-yaml-path --- call-for-testing/README.md | 16 ++++++------- call-for-testing/action.yaml | 6 ++--- get-architectures/README.md | 6 ++--- get-architectures/action.yaml | 6 ++--- get-screenshots/README.md | 18 +++++++------- get-screenshots/action.yaml | 6 ++--- parse-snapcraft-yaml/README.md | 25 +++++++++---------- parse-snapcraft-yaml/action.yaml | 41 ++++++++++++++++++-------------- promote-to-stable/README.md | 12 +++++----- promote-to-stable/action.yaml | 6 ++--- release-to-candidate/README.md | 14 +++++------ release-to-candidate/action.yaml | 8 ++++--- sync-version/README.md | 10 ++++---- sync-version/action.yaml | 6 ++--- test-snap-build/README.md | 8 +++---- test-snap-build/action.yaml | 8 +++---- 16 files changed, 102 insertions(+), 94 deletions(-) diff --git a/call-for-testing/README.md b/call-for-testing/README.md index a7978fe..deb1bad 100644 --- a/call-for-testing/README.md +++ b/call-for-testing/README.md @@ -60,14 +60,14 @@ jobs: ### Inputs -| Key | Description | Required | Default | -| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------: | :---------------- | -| `architectures` | The architectures that the snap supports. | Y | | -| `ci-repo` | The repo to fetch tools/templates from. Only for debugging. | N | `snapcrafters/ci` | -| `channel` | The channel to create the call for testing for. | N | `candidate` | -| `github-token` | A token with permissions to create issues on the repository. | Y | | -| `snapcraft-yaml-path` | The path to the `snapcraft.yaml` file. | N | -| `store-token` | A token with permissions to query the specified channel in the Snap Store. Only required if the revisions to test are not passed to the workflow by the `release-to-candidate` workflow | N | | +| Key | Description | Required | Default | +| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------: | :---------------- | +| `architectures` | The architectures that the snap supports. | Y | | +| `ci-repo` | The repo to fetch tools/templates from. Only for debugging. | N | `snapcrafters/ci` | +| `channel` | The channel to create the call for testing for. | N | `candidate` | +| `github-token` | A token with permissions to create issues on the repository. | Y | | +| `snapcraft-project-root` | The root of the snapcraft project, where the `snapcraft` command would usually be executed from. Do not include the trailing `/`. | N | +| `store-token` | A token with permissions to query the specified channel in the Snap Store. Only required if the revisions to test are not passed to the workflow by the `release-to-candidate` workflow | N | | ### Outputs diff --git a/call-for-testing/action.yaml b/call-for-testing/action.yaml index c071375..5d1571d 100644 --- a/call-for-testing/action.yaml +++ b/call-for-testing/action.yaml @@ -20,8 +20,8 @@ inputs: github-token: description: "A token with permissions to create issues on the repository" required: true - snapcraft-yaml-path: - description: "Custom path to snapcraft.yaml for when it is not in the default location." + snapcraft-project-root: + description: "The root of the snapcraft project, where the `snapcraft` command would usually be executed from." required: false store-token: description: "A token with permissions to upload to the specified channel" @@ -53,7 +53,7 @@ runs: id: snapcraft-yaml uses: snapcrafters/ci/parse-snapcraft-yaml@main with: - snapcraft-yaml-path: ${{ inputs.snapcraft-yaml-path }} + snapcraft-project-root: ${{ inputs.snapcraft-project-root }} - name: Write the arch/rev table shell: bash diff --git a/get-architectures/README.md b/get-architectures/README.md index c2ac587..e7852d8 100644 --- a/get-architectures/README.md +++ b/get-architectures/README.md @@ -24,9 +24,9 @@ jobs: ### Inputs -| Key | Description | Required | Default | -| --------------------- | -------------------------------------- | :------: | :------ | -| `snapcraft-yaml-path` | The path to the `snapcraft.yaml` file. | N | | +| Key | Description | Required | Default | +| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | :------: | :------ | +| `snapcraft-project-root` | The root of the snapcraft project, where the `snapcraft` command would usually be executed from. Do not include the trailing `/`. | N | | ### Outputs diff --git a/get-architectures/action.yaml b/get-architectures/action.yaml index 78edd1f..6098a50 100644 --- a/get-architectures/action.yaml +++ b/get-architectures/action.yaml @@ -6,8 +6,8 @@ branding: color: orange inputs: - snapcraft-yaml-path: - description: "Custom path to snapcraft.yaml for when it is not in the default location." + snapcraft-project-root: + description: "The root of the snapcraft project, where the `snapcraft` command would usually be executed from." required: false outputs: @@ -28,7 +28,7 @@ runs: id: snapcraft-yaml uses: snapcrafters/ci/parse-snapcraft-yaml@main with: - snapcraft-yaml-path: ${{ inputs.snapcraft-yaml-path }} + snapcraft-project-root: ${{ inputs.snapcraft-project-root }} - name: Compute architectures id: architectures diff --git a/get-screenshots/README.md b/get-screenshots/README.md index c65955f..4f08371 100644 --- a/get-screenshots/README.md +++ b/get-screenshots/README.md @@ -27,15 +27,15 @@ jobs: ### Inputs -| Key | Description | Required | Default | -| --------------------- | ------------------------------------------------------------------------------------------------------------------ | :------: | :---------------------------- | -| `issue-number` | The issue number to post the screenshots to. | Y | | -| `ci-repo` | The repo to fetch tools/templates from. Only for debugging. | N | `snapcrafters/ci` | -| `channel` | The channel to create the call for testing for. | N | `candidate` | -| `github-token` | A token with permissions to common on issues in the repository. | Y | | -| `screenshots-repo` | The repository where screenshots should be uploaded. | N | `snapcrafters/ci-screenshots` | -| `screenshots-token` | A token with permissions to commit screenshots to [ci-screenshots](https://github.com/snapcrafters/ci-screenshots) | Y | | -| `snapcraft-yaml-path` | The path to the `snapcraft.yaml` file. | N | +| Key | Description | Required | Default | +| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | :------: | :---------------------------- | +| `issue-number` | The issue number to post the screenshots to. | Y | | +| `ci-repo` | The repo to fetch tools/templates from. Only for debugging. | N | `snapcrafters/ci` | +| `channel` | The channel to create the call for testing for. | N | `candidate` | +| `github-token` | A token with permissions to common on issues in the repository. | Y | | +| `screenshots-repo` | The repository where screenshots should be uploaded. | N | `snapcrafters/ci-screenshots` | +| `screenshots-token` | A token with permissions to commit screenshots to [ci-screenshots](https://github.com/snapcrafters/ci-screenshots) | Y | | +| `snapcraft-project-root` | The root of the snapcraft project, where the `snapcraft` command would usually be executed from. Do not include the trailing `/`. | N | ### Outputs diff --git a/get-screenshots/action.yaml b/get-screenshots/action.yaml index b74c864..5ed8357 100644 --- a/get-screenshots/action.yaml +++ b/get-screenshots/action.yaml @@ -20,8 +20,8 @@ inputs: github-token: description: "A token with permissions to comment on issues" required: true - snapcraft-yaml-path: - description: "Custom path to snapcraft.yaml for when it is not in the default location." + snapcraft-project-root: + description: "The root of the snapcraft project, where the `snapcraft` command would usually be executed from." required: false screenshots-repo: description: "The repository where screenshots should be uploaded." @@ -58,7 +58,7 @@ runs: id: snapcraft-yaml uses: snapcrafters/ci/parse-snapcraft-yaml@main with: - snapcraft-yaml-path: ${{ inputs.snapcraft-yaml-path }} + snapcraft-project-root: ${{ inputs.snapcraft-project-root }} - name: Prepare VM shell: bash diff --git a/parse-snapcraft-yaml/README.md b/parse-snapcraft-yaml/README.md index 8a33f36..624417b 100644 --- a/parse-snapcraft-yaml/README.md +++ b/parse-snapcraft-yaml/README.md @@ -2,7 +2,7 @@ This action is more for use internally than otherwise. It's purpose is to either find a snapcraft.yaml file from a list of known common locations in a repository, or take the path to a snapcraft.yaml, then parse some information from it and provide that information as outputs. -You only need to specify the `snapcraft-yaml-path` input if your `snapcraft.yaml` is not in one of the following locations: +You only need to specify the `snapcraft-project-root` input if your `snapcraft.yaml` is not in one of the following locations: - `.snapcraft.yaml` - `build-aux/snap/snapcraft.yaml` @@ -34,17 +34,18 @@ jobs: ### Inputs -| Key | Description | Required | Default | -| --------------------- | -------------------------------------- | :------: | :------ | -| `snapcraft-yaml-path` | The path to the `snapcraft.yaml` file. | N | | +| Key | Description | Required | Default | +| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | :------: | :------ | +| `snapcraft-project-root` | The root of the snapcraft project, where the `snapcraft` command would usually be executed from. Do not include the trailing `/`. | N | | ### Outputs -| Key | Description | Example | -| ------------ | ----------------------------------------------------------------------------------- | -------------------------- | -| `classic` | Whether to snap is strictly confined | `false` | -| `plugs-file` | The location of a plugs declaration file to be used during review, if one was found | `./plugs-declaration.json` | -| `slots-file` | The location of a slots declaration file to be used during review, if one was found | `./slots-declaration.json` | -| `snap_name` | The name of the snap as declared in the snapcraft.yaml | `signal-desktop` | -| `version` | The version declared in the snapcraft.yaml file | `6.41.0` | -| `yaml_path` | The path to the snapcraft.yaml for the project | `snap/snapcraft.yaml` | +| Key | Description | Example | +| -------------- | ------------------------------------------------------------------------------------------------ | -------------------------- | +| `classic` | Whether to snap is strictly confined | `false` | +| `plugs-file` | The location of a plugs declaration file to be used during review, if one was found | `./plugs-declaration.json` | +| `project-root` | The root of the snapcraft project, where the `snapcraft` command would usually be executed from. | `./ffmpeg-2204-sdk` | +| `slots-file` | The location of a slots declaration file to be used during review, if one was found | `./slots-declaration.json` | +| `snap_name` | The name of the snap as declared in the snapcraft.yaml | `signal-desktop` | +| `version` | The version declared in the snapcraft.yaml file | `6.41.0` | +| `yaml_path` | The path to the snapcraft.yaml for the project | `snap/snapcraft.yaml` | diff --git a/parse-snapcraft-yaml/action.yaml b/parse-snapcraft-yaml/action.yaml index e66a212..225e517 100644 --- a/parse-snapcraft-yaml/action.yaml +++ b/parse-snapcraft-yaml/action.yaml @@ -6,8 +6,8 @@ branding: color: orange inputs: - snapcraft-yaml-path: - description: "Custom path to snapcraft.yaml for when it is not in the default location." + snapcraft-project-root: + description: "The root of the snapcraft project, where the `snapcraft` command would usually be executed from. Do not include trailing `/`." required: false outputs: @@ -17,6 +17,9 @@ outputs: plugs-file: description: "The location of a plugs declaration file to be used during review, if one was found" value: ${{ steps.parse.outputs.plugs-file }} + project-root: + description: "The root of the snapcraft project, where the `snapcraft` command would usually be executed from." + value: ${{ steps.parse.outputs.project-root }} slots-file: description: "The location of a slots declaration file to be used during review, if one was found" value: ${{ steps.parse.outputs.slots-file }} @@ -39,23 +42,24 @@ runs: - name: Find and parse snapcraft.yaml id: parse shell: bash + env: + project_root: ${{ inputs.snapcraft-project-root }} run: | - if [[ -n "${{ inputs.snapcraft-yaml-path }}" ]]; then - yaml_path="${{ inputs.snapcraft-yaml-path }}" - else - common_paths=( - ".snapcraft.yaml" - "build-aux/snap/snapcraft.yaml" - "snap/snapcraft.yaml" - "snapcraft.yaml" - ) - - for file in "${common_paths[@]}"; do - if [[ -f "$file" ]]; then - yaml_path="$file" - fi - done - fi + # If no project path is specified, default to top-level of repo + project_root="${project_root:-.}" + + valid_paths=( + "${project_root}/.snapcraft.yaml" + "${project_root}/build-aux/snap/snapcraft.yaml" + "${project_root}/snap/snapcraft.yaml" + "${project_root}/snapcraft.yaml" + ) + + for file in "${valid_paths[@]}"; do + if [[ -f "$file" ]]; then + yaml_path="$file" + fi + done if [[ -z "${yaml_path}" ]]; then echo "No snapcraft.yaml found" @@ -86,6 +90,7 @@ runs: fi done + echo "project-root=${project_root}" >> "$GITHUB_OUTPUT" echo "yaml-path=${yaml_path}" >> "$GITHUB_OUTPUT" echo "snap-name=$(yq -r '.name' "$yaml_path")" >> "$GITHUB_OUTPUT" echo "version=$(yq -r '.version' "$yaml_path")" >> "$GITHUB_OUTPUT" diff --git a/promote-to-stable/README.md b/promote-to-stable/README.md index a1da8fc..2966da5 100644 --- a/promote-to-stable/README.md +++ b/promote-to-stable/README.md @@ -27,12 +27,12 @@ jobs: ### Inputs -| Key | Description | Required | Default | -| --------------------- | ---------------------------------------------------------------------------------------- | :------: | :------ | -| `github-token` | A token with permissions to write issues on the repository | Y | | -| `store-token` | A token with permissions to upload and release to the `stable` channel in the Snap Store | Y | | -| `snap-name` | The name of the snap to promote | N | | -| `snapcraft-yaml-path` | The path to the `snapcraft.yaml` file. | N | +| Key | Description | Required | Default | +| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | :------: | :------ | +| `github-token` | A token with permissions to write issues on the repository | Y | | +| `store-token` | A token with permissions to upload and release to the `stable` channel in the Snap Store | Y | | +| `snap-name` | The name of the snap to promote | N | | +| `snapcraft-project-root` | The root of the snapcraft project, where the `snapcraft` command would usually be executed from. Do not include the trailing `/`. | N | ### Outputs diff --git a/promote-to-stable/action.yaml b/promote-to-stable/action.yaml index 24de7f4..1794ba6 100644 --- a/promote-to-stable/action.yaml +++ b/promote-to-stable/action.yaml @@ -9,8 +9,8 @@ inputs: github-token: description: "A token with permissions to write issues on the repository" required: true - snapcraft-yaml-path: - description: "Custom path to snapcraft.yaml for when it is not in the default location." + snapcraft-project-root: + description: "The root of the snapcraft project, where the `snapcraft` command would usually be executed from." required: false store-token: description: "A token with permissions to upload to the specified channel" @@ -56,7 +56,7 @@ runs: id: snapcraft-yaml uses: snapcrafters/ci/parse-snapcraft-yaml@main with: - snapcraft-yaml-path: ${{ inputs.snapcraft-yaml-path }} + snapcraft-project-root: ${{ inputs.snapcraft-project-root }} - name: Promote snap to latest/stable id: promote diff --git a/release-to-candidate/README.md b/release-to-candidate/README.md index 8e15b04..c87f8ec 100644 --- a/release-to-candidate/README.md +++ b/release-to-candidate/README.md @@ -24,13 +24,13 @@ jobs: ### Inputs -| Key | Description | Required | Default | -| --------------------- | ----------------------------------------------------------------------------------------- | :------: | :---------- | -| `architecture` | The architecture for which to build the snap. | N | `amd64` | -| `channel` | The channel to release the snap to. | N | `candidate` | -| `launchpad-token` | A token with permissions to create Launchpad remote builds. | Y | | -| `snapcraft-yaml-path` | The path to the Snapcraft YAML file. | N | | -| `store-token` | A token with permissions to upload and release to the specified channel in the Snap Store | Y | | +| Key | Description | Required | Default | +| ------------------------ | ----------------------------------------------------------------------------------------- | :------: | :---------- | +| `architecture` | The architecture for which to build the snap. | N | `amd64` | +| `channel` | The channel to release the snap to. | N | `candidate` | +| `launchpad-token` | A token with permissions to create Launchpad remote builds. | Y | | +| `snapcraft-project-root` | The path to the Snapcraft YAML file. | N | | +| `store-token` | A token with permissions to upload and release to the specified channel in the Snap Store | Y | | ### Outputs diff --git a/release-to-candidate/action.yaml b/release-to-candidate/action.yaml index 4784c64..334ce9b 100644 --- a/release-to-candidate/action.yaml +++ b/release-to-candidate/action.yaml @@ -17,8 +17,8 @@ inputs: launchpad-token: description: "A token with permissions to create remote builds on Launchpad" required: true - snapcraft-yaml-path: - description: "Custom path to snapcraft.yaml for when it is not in the default location." + snapcraft-project-root: + description: "The root of the snapcraft project, where the `snapcraft` command would usually be executed from." required: false store-token: description: "A token with permissions to upload to the specified channel" @@ -50,7 +50,7 @@ runs: id: snapcraft-yaml uses: snapcrafters/ci/parse-snapcraft-yaml@main with: - snapcraft-yaml-path: ${{ inputs.snapcraft-yaml-path }} + snapcraft-project-root: ${{ inputs.snapcraft-project-root }} - name: Build the snap (${{ inputs.architecture }}) id: build @@ -60,11 +60,13 @@ runs: name: ${{ steps.snapcraft-yaml.outputs.snap-name }} yaml_path: ${{ steps.snapcraft-yaml.outputs.yaml-path }} version: ${{ steps.snapcraft-yaml.outputs.version }} + project_root: ${{ steps.snapcraft-yaml.outputs.project-root }} run: | # Remove the architecture definition from the snapcraft.yaml due to: # https://bugs.launchpad.net/snapcraft/+bug/1885150 yq -i 'del(.architectures)' "$yaml_path" + cd "$project_root" || exit snapcraft remote-build --launchpad-accept-public-upload --build-for="${arch}" if [[ ! -e "${name}_${version}_${arch}.snap" ]]; then diff --git a/sync-version/README.md b/sync-version/README.md index 18bf8ae..2146bc8 100644 --- a/sync-version/README.md +++ b/sync-version/README.md @@ -28,11 +28,11 @@ jobs: ### Inputs -| Key | Description | Required | -| --------------------- | -------------------------------------------------------------------------------------------------- | :------: | -| `snapcraft-yaml-path` | The path to the `snapcraft.yaml` file. | N | -| `token` | A token with permissions to commit to the repository. | Y | -| `update-script` | A script that checks for version updates and updates `snapcraft.yaml` and other files if required. | Y | +| Key | Description | Required | +| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | :------: | +| `snapcraft-project-root` | The root of the snapcraft project, where the `snapcraft` command would usually be executed from. Do not include the trailing `/`. | N | +| `token` | A token with permissions to commit to the repository. | Y | +| `update-script` | A script that checks for version updates and updates `snapcraft.yaml` and other files if required. | Y | ### Outputs diff --git a/sync-version/action.yaml b/sync-version/action.yaml index e0089ba..eca5678 100644 --- a/sync-version/action.yaml +++ b/sync-version/action.yaml @@ -6,8 +6,8 @@ branding: color: orange inputs: - snapcraft-yaml-path: - description: "Custom path to snapcraft.yaml for when it is not in the default location." + snapcraft-project-root: + description: "The root of the snapcraft project, where the `snapcraft` command would usually be executed from." required: false token: required: true @@ -28,7 +28,7 @@ runs: id: snapcraft-yaml uses: snapcrafters/ci/parse-snapcraft-yaml@main with: - snapcraft-yaml-path: ${{ inputs.snapcraft-yaml-path }} + snapcraft-project-root: ${{ inputs.snapcraft-project-root }} - name: Run update script shell: bash diff --git a/test-snap-build/README.md b/test-snap-build/README.md index 7d27acb..967659f 100644 --- a/test-snap-build/README.md +++ b/test-snap-build/README.md @@ -34,10 +34,10 @@ jobs: ### Inputs -| Key | Description | Required | Default | -| --------------------- | -------------------------------------------------------------- | :------: | :------ | -| `install` | If `true`, the built snap is install on the runner after build | N | `false` | -| `snapcraft-yaml-path` | The path to the Snapcraft YAML file. | N | | +| Key | Description | Required | Default | +| ------------------------ | -------------------------------------------------------------- | :------: | :------ | +| `install` | If `true`, the built snap is install on the runner after build | N | `false` | +| `snapcraft-project-root` | The path to the Snapcraft YAML file. | N | | ### Outputs diff --git a/test-snap-build/action.yaml b/test-snap-build/action.yaml index 6c19f34..359ed7d 100644 --- a/test-snap-build/action.yaml +++ b/test-snap-build/action.yaml @@ -10,8 +10,8 @@ inputs: description: "Option to install the snap on the runner after build" default: "false" required: false - snapcraft-yaml-path: - description: "Custom path to snapcraft.yaml for when it is not in the default location." + snapcraft-project-root: + description: "The root of the snapcraft project, where the `snapcraft` command would usually be executed from." required: false runs: @@ -24,13 +24,13 @@ runs: id: snapcraft-yaml uses: snapcrafters/ci/parse-snapcraft-yaml@main with: - snapcraft-yaml-path: ${{ inputs.snapcraft-yaml-path }} + snapcraft-project-root: ${{ inputs.snapcraft-project-root }} - name: Build snap uses: snapcore/action-build@v1 id: build with: - path: ${{ steps.snapcraft-yaml.outputs.yaml-path }} + path: ${{ steps.snapcraft-yaml.outputs.project-root }} - name: Review the built snap uses: diddlesnaps/snapcraft-review-action@v1