Skip to content
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
45 changes: 45 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Lint Pull Requests"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: write

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.

Details:

```
${{ steps.lint_pr_title.outputs.error_message }}
```

# Delete a previous comment when the issue has been resolved
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
delete: true
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add installer and jython binaries caching
- Add `cache-hit` output value, which is set to `true` if the Jython data/binaries are retrieved from cache.

## [v5] - 2024-05-16

### Added

- Now it is possible to use Jython 2.0 and 2.1 on `ubuntu` and `macos` runners!
- Added support for Powershell on all runners (previously only on `windows` runners)
- Added support for Windows Command Prompt (`cmd`) on windows runners. Notice that because of how the `cmd` handles single quotes it only works if no single quotes are used to enclose parameters: `jython.bat -c "print 'Hello world'"` will work, while `jython.bat -c 'print "Hello world"'` will not.
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ Specify the path where Jython will be installed. Please note that this is usuall
</tbody>
</table>

## Outputs

### `download-url`

The URL from which the Jython installer was downloaded.

### `cache-hit`

Boolean value that indicates whether a cache hit occurred on the primary key.

## Supported versions

This action supports all versions (_both stable and development releases_) currently listed on the official repositories:
Expand Down
38 changes: 32 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ outputs:
download-url:
description: "The URL from which the installer is downloaded"
value: ${{ steps.find_installer.outputs.url }}
cache-hit:
description: "Whether the Jython binaries were restored from the cache"
value: ${{ steps.cache-jython.outputs.cache-hit }}

runs:
using: "composite"
Expand All @@ -29,9 +32,34 @@ runs:
echo "Action running on ${{ runner.os }} ${{ runner.arch }} (name: '${{ runner.name }}')"
shell: bash

# See https://github.com/actions/toolkit/issues/1035
- uses: actions/github-script@v7
id: resources-hash
with:
script: return require('fs').createReadStream(require('path').join(process.env.GITHUB_ACTION_PATH, 'bin', 'resources.json')).pipe(require('crypto').createHash('sha1').setEncoding('hex'), 'finish').digest('hex')
result-encoding: string

- name: Cache Jython binaries
id: cache-jython
uses: actions/cache@v4
with:
key: ${{ runner.os }}-${{ runner.arch }}-${{ inputs.jython-version }}-${{ steps.resources-hash.outputs.result }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-${{ inputs.jython-version }}-
path: |
${{ inputs.installation-path }}
~/.local/bin/

- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'zulu'

# Sadly, macos-latest images use Python 2.7 (dunno why)
- name: Find Jython installer from resource list
id: find_installer
if: ${{ steps.cache-jython.outputs.cache-hit != 'true' }}
shell: python
run: |
import sys, os
Expand Down Expand Up @@ -75,14 +103,9 @@ runs:
]
f.write('\n'.join(lines))

- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'zulu'

- name: Download Jython Installer
id: download_installer
if: ${{ steps.cache-jython.outputs.cache-hit != 'true' }}
shell: bash
run: |
download_url="${{ steps.find_installer.outputs.url }}";
Expand All @@ -96,6 +119,7 @@ runs:

- name: Install Jython
id: installation
if: ${{ steps.cache-jython.outputs.cache-hit != 'true' }}
shell: bash
run: |
case "${{ steps.find_installer.outputs.file_type }}" in
Expand Down Expand Up @@ -138,6 +162,7 @@ runs:
# rm -f ${{ steps.download_installer.outputs.temporary_file }}

- name: Setup Jython alias
if: ${{ steps.cache-jython.outputs.cache-hit != 'true' }}
shell: bash
run: |
installation_path="$(sed -r 's/^\s+//; s/\s+$//; s/\/+$//;' <<< "${{ inputs.installation-path }}")"
Expand Down Expand Up @@ -166,6 +191,7 @@ runs:
chmod +x ~/.local/bin/jython;

- name: Setup Jython alias (pwsh)
if: ${{ steps.cache-jython.outputs.cache-hit != 'true' }}
shell: pwsh
run: |
$installation_path = Convert-Path "${{ inputs.installation-path }}"
Expand Down