Skip to content
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

fix: specify snapcraft-project-root instead of snapcraft-yaml-path #20

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions call-for-testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions call-for-testing/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions get-architectures/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions get-architectures/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions get-screenshots/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions get-screenshots/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down
25 changes: 13 additions & 12 deletions parse-snapcraft-yaml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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` |
41 changes: 23 additions & 18 deletions parse-snapcraft-yaml/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand All @@ -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"
Expand Down Expand Up @@ -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"
12 changes: 6 additions & 6 deletions promote-to-stable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions promote-to-stable/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Loading