Skip to content

Commit 19cb54f

Browse files
authored
Create initial julia-version implementation (#3)
* Initial draft * Add tests * Tests and drop tc * Fix linting * Drop arch input * Test for transpiled * node-fetch testing mess * Experiment with fetch wrapper * Jest mostly functional * Use nock for HTTP mocking * Flush out main tests * Use node prefix on import * Remove wait * Improve CI action test * Use versions.json for testVersions * Simplify updating tests * Drop quotes * Show resolved version in CI * Initial support for multiple versions * Support YAML input handling * Document version specifier syntax * Refactoring to fall inline with documentation * Validate input version specifiers * Functionality in place * Fix GHA test * Linting fixes * Input fix * Set output to resolved * Fix regex tests * Add GHA example * Add CONTRIBUTION guide * Document inputs/outputs * Allow inline HTML in tables * Prettier ignoring markdown table * Fix GHA example test * Create separate example workflow * Add tests for resolveVersionSpecifiers * Rename functions * Return unique * Add more docstrings * Set version to 0.1.0 * Rename output `unique` to `unique-json` * Provide scalar output `version` * Use more basic Backus-Naur form * Update CONTRIBUTING on installing Node.js * Add additional version input test * Add YAML decimal conversion test * Confirm nightly check performance When confirming `1.12-nightly` I saw 9s on the initial check and 1s on follow up checks. * Add guidance to CONTRIBUTING.md * Use string literal type for if-missing * Skip non-functional tests * Fix dotenv linter
1 parent 9e7f1b0 commit 19cb54f

34 files changed

+45935
-728
lines changed

.env

+9-6
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
# may be useful to set it to `true`.
88
ACTIONS_STEP_DEBUG="true"
99

10-
# GitHub Actions inputs should follow `INPUT_<name>` format (case-sensitive).
10+
# GitHub Actions inputs should follow `INPUT_<name>` format (case-insensitive).
1111
# Hyphens should not be converted to underscores!
12-
INPUT_MILLISECONDS=2400
12+
# dotenv-linter:off IncorrectDelimiter, LowercaseKey
13+
INPUT_if-missing="warn"
14+
INPUT_versions="[lts, 1, ~1.10, 1.9-nightly, nightly]"
15+
# dotenv-linter:on IncorrectDelimiter, LowercaseKey
1316

1417
# GitHub Actions default environment variables. These are set for every run of a
1518
# workflow and can be used in your actions. Setting the value here will override
1619
# any value set by the local-action tool.
1720
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
1821

19-
# CI="true"
22+
CI="true"
2023
# GITHUB_ACTION=""
2124
# GITHUB_ACTION_PATH=""
2225
# GITHUB_ACTION_REPOSITORY=""
@@ -53,9 +56,9 @@ INPUT_MILLISECONDS=2400
5356
# GITHUB_WORKFLOW_REF=""
5457
# GITHUB_WORKFLOW_SHA=""
5558
# GITHUB_WORKSPACE=""
56-
# RUNNER_ARCH=""
59+
RUNNER_ARCH="X64"
5760
# RUNNER_DEBUG=""
5861
# RUNNER_NAME=""
59-
# RUNNER_OS=""
60-
# RUNNER_TEMP=""
62+
RUNNER_OS="Linux"
63+
RUNNER_TEMP="/tmp/julia-version"
6164
# RUNNER_TOOL_CACHE=""

.github/workflows/check-dist.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ name: Check Transpiled JavaScript
1212

1313
on:
1414
pull_request:
15-
branches:
16-
- main
1715
push:
1816
branches:
1917
- main

.github/workflows/ci.yaml

+54-20
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,82 @@ jobs:
1616
runs-on: ubuntu-latest
1717

1818
steps:
19-
- name: Checkout
20-
id: checkout
21-
uses: actions/checkout@v4
19+
- uses: actions/checkout@v4
2220

23-
- name: Setup Node.js
24-
id: setup-node
25-
uses: actions/setup-node@v4
21+
- uses: actions/setup-node@v4
2622
with:
2723
node-version-file: .node-version
2824
cache: npm
2925

3026
- name: Install Dependencies
31-
id: npm-ci
3227
run: npm ci
3328

3429
- name: Check Format
35-
id: npm-format-check
3630
run: npm run format:check
3731

3832
- name: Lint
39-
id: npm-lint
4033
run: npm run lint
4134

4235
- name: Test
43-
id: npm-ci-test
4436
run: npm run ci-test
4537

4638
test-action:
4739
name: GitHub Actions Test
40+
permissions:
41+
contents: read
4842
runs-on: ubuntu-latest
49-
5043
steps:
51-
- name: Checkout
52-
id: checkout
53-
uses: actions/checkout@v4
44+
- uses: actions/checkout@v4
45+
46+
- name: Create Project.toml
47+
shell: bash
48+
run: |
49+
echo -e '[compat]\njulia = "1.6"' >Project.toml
50+
51+
- name: Test julia-version
52+
id: julia-version
53+
uses: ./
54+
with:
55+
versions: |
56+
- min
57+
- lts
58+
- 1
59+
- ~1.10
60+
if-missing: error
5461

55-
- name: Test Local Action
56-
id: test-action
62+
- name: Validate output
63+
shell: bash
64+
run: |
65+
set -x
66+
[[ "$(jq -r 'length' <<<"$unique_json")" -eq 3 ]] || exit 1
67+
[[ "$(jq -r '.[0]' <<<"$unique_json")" == "1.6.0" ]] || exit 1
68+
[[ "$(jq -r '.[1]' <<<"$unique_json")" =~ ^1\.10\.([8-9]|[1-9][0-9]*)$ ]] || exit 1 # [1.10.8, 1.11.0)
69+
[[ "$(jq -r '.[2]' <<<"$unique_json")" =~ ^1\.(1[1-9]|2[0-9]+)\.[0-9]+$ ]] || exit 1 # [1.11.0, ∞)
70+
71+
[[ "$version" == "" ]] || exit 1
72+
env:
73+
unique_json: ${{ steps.julia-version.outputs.unique-json }}
74+
version: ${{ steps.julia-version.outputs.version }}
75+
76+
test-yaml-dec:
77+
name: YAML Decimal Test
78+
permissions:
79+
contents: read
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v4
83+
- name: Test julia-version
84+
id: julia-version
5785
uses: ./
5886
with:
59-
milliseconds: 2000
87+
versions: 1.10 # !!! IMPORTANT: Do not do this. You should always pass in a string
88+
if-missing: error
6089

61-
- name: Print Output
62-
id: output
63-
run: echo "${{ steps.test-action.outputs.time }}"
90+
- name: Validate output
91+
shell: bash
92+
run: |
93+
set -x
94+
# User expects "1.10.*"
95+
[[ "$version" == "1.1.1" ]] || exit 1
96+
env:
97+
version: ${{ steps.julia-version.outputs.version }}

.github/workflows/example.yaml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
name: Example
3+
on:
4+
pull_request: {}
5+
push:
6+
branches:
7+
- main
8+
9+
# These permissions are needed to:
10+
# - Checkout the Git repository (`contents: read`)
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
version:
16+
name: Resolve Julia Versions
17+
runs-on: ubuntu-latest
18+
outputs:
19+
json: ${{ steps.julia-version.outputs.unique-json }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Create Project.toml
23+
shell: bash
24+
run: |
25+
# Need Julia 1.8 for `macos-latest` which defaults to Apple Silicon (aarch64)
26+
echo -e '[compat]\njulia = "1.8"' >Project.toml
27+
- uses: ./
28+
id: julia-version
29+
with:
30+
versions: |
31+
- min # Oldest supported version
32+
- lts # Long-Term Stable
33+
- 1 # Latest release
34+
35+
test:
36+
# e.g. `Julia 1.10.8 - ubuntu-latest`
37+
name: Julia ${{ matrix.version }} - ${{ matrix.os }}
38+
needs: version
39+
runs-on: ${{ matrix.os }}
40+
strategy:
41+
matrix:
42+
version: ${{ fromJSON(needs.version.outputs.json) }}
43+
os:
44+
- ubuntu-latest
45+
- windows-latest
46+
- macos-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: julia-actions/setup-julia@v2
50+
with:
51+
version: ${{ matrix.version }}
52+
- name: Julia version info
53+
shell: julia --color=yes {0}
54+
run: |
55+
using InteractiveUtils
56+
versioninfo()

CONTRIBUTING.md

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# Contributing
2+
3+
## Initial Setup
4+
5+
After you've cloned the repository to your local machine or codespace, you'll
6+
need to perform some initial setup steps before you can develop your action.
7+
8+
1. Install a [Node.js](https://nodejs.org). If you are using a version manager
9+
like [`nodenv`](https://github.com/nodenv/nodenv) or
10+
[`fnm`](https://github.com/Schniz/fnm), thispackage has a `.node-version`
11+
file at the root of the repository that can be used to automatically switch
12+
to the correct version when you `cd` into this repository.
13+
14+
2. Install the dependencies
15+
16+
```bash
17+
npm install
18+
```
19+
20+
3. Verify the tests pass
21+
22+
```bash
23+
$ npm test
24+
25+
PASS __tests__/main.test.ts
26+
run
27+
✓ Sets the version output (30 ms)
28+
✓ Sets a failed status (8 ms)
29+
30+
...
31+
```
32+
33+
## Update the Action Metadata
34+
35+
The [`action.yaml`](./action.yaml) file defines metadata about the action, such
36+
as input(s) and output(s). For details about this file, see
37+
[Metadata syntax for GitHub Actions](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions).
38+
39+
## Update the Action Code
40+
41+
1. Create a new branch
42+
43+
```bash
44+
git checkout -b js/my-feature
45+
```
46+
47+
2. Make your changes to the action code in `src`.
48+
49+
Any changes to the regular expressions in `src/input.ts` should be reflected
50+
in the Backus-Naur grammar in the `README.md`.
51+
52+
3. Add tests to `__tests__` for your changes. If you need mock function calls we
53+
use `nock` for HTTP requests and `jest` for everything else.
54+
55+
If required you may update the `__fixtures__/versions.json` file via
56+
`curl -fsSL https://julialang-s3.julialang.org/bin/versions.json >__fixtures__/versions.json`.
57+
Some tests will need to be updated if there are changes to `versions.json`.
58+
59+
4. (Optional) Run the tests
60+
61+
```bash
62+
npm test
63+
```
64+
65+
5. (Optional) Test your action locally
66+
67+
The [`@github/local-action`](https://github.com/github/local-action) utility
68+
can be used to test your action locally. It is a simple command-line tool
69+
that "stubs" (or simulates) the GitHub Actions Toolkit. This way, you can run
70+
your TypeScript action locally without having to commit and push your changes
71+
to a repository.
72+
73+
The `local-action` utility can be run in the following ways:
74+
75+
- Visual Studio Code Debugger
76+
77+
Make sure to review and, if needed, update
78+
[`.vscode/launch.json`](./.vscode/launch.json)
79+
80+
- Terminal/Command Prompt
81+
82+
```bash
83+
# npx local action <action-yaml-path> <entrypoint> <dotenv-file>
84+
npx local-action . src/main.ts .env
85+
```
86+
87+
You can provide a [`.env`](./.env) file to the `local-action` CLI to set
88+
environment variables used by the GitHub Actions Toolkit. For example,
89+
setting inputs and event payload data used by your action. For more
90+
information see the
91+
[GitHub Actions Documentation](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables).
92+
93+
6. Format, test, and build the action
94+
95+
```bash
96+
npm run all
97+
```
98+
99+
> This step is important! It will run [`rollup`](https://rollupjs.org/) to
100+
> build the final JavaScript action code with all dependencies included. If
101+
> you do not run this step, your pushed changes will not work correctly when
102+
> it is used in a workflow.
103+
104+
7. Commit your changes
105+
106+
```bash
107+
git add .
108+
git commit -m "My feature"
109+
```
110+
111+
8. Push your changes
112+
113+
```bash
114+
git push
115+
```
116+
117+
9. Create a pull request and wait for feedback or approval
118+
10. Merge the pull request into the `main` branch
119+
120+
Your action changes are now published! :rocket:
121+
122+
## Publishing a New Release
123+
124+
This action follows the standard procedures around
125+
[versioning GitHub Actions](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md).
126+
The helper script, [`script/release`](./script/release) is used to streamline
127+
the process of tagging and pushing new releases for GitHub Actions.
128+
129+
GitHub Actions allows users to select a specific version of the action to use,
130+
based on release tags. This script simplifies this process by performing the
131+
following steps:
132+
133+
1. **Retrieving the latest release tag:** The script starts by fetching the most
134+
recent SemVer release tag of the current branch, by looking at the local data
135+
available in your repository.
136+
2. **Prompting for a new release tag:** The user is then prompted to enter a new
137+
release tag. To assist with this, the script displays the tag retrieved in
138+
the previous step, and validates the format of the inputted tag (vX.X.X). The
139+
user is also reminded to update the version field in package.json.
140+
3. **Tagging the new release:** The script then tags a new release and syncs the
141+
separate major tag (e.g. v1, v2) with the new release tag (e.g. v1.0.0,
142+
v2.1.2). When the user is creating a new major release, the script
143+
auto-detects this and creates a `releases/v#` branch for the previous major
144+
version.
145+
4. **Pushing changes to remote:** Finally, the script pushes the necessary
146+
commits, tags and branches to the remote repository. From here, you will need
147+
to create a new release in GitHub so users can easily reference the new tags
148+
in their workflows.
149+
150+
## Dependency License Management
151+
152+
This template includes a GitHub Actions workflow,
153+
[`licensed.yaml`](./.github/workflows/licensed.yaml), that uses
154+
[Licensed](https://github.com/licensee/licensed) to check for dependencies with
155+
missing or non-compliant licenses. Currently this workflow is initially
156+
disabled. To enable the workflow, follow the below steps.
157+
158+
1. Open [`licensed.yaml`](./.github/workflows/licensed.yaml)
159+
2. Uncomment the following lines:
160+
161+
```yaml
162+
# pull_request:
163+
# branches:
164+
# - main
165+
# push:
166+
# branches:
167+
# - main
168+
```
169+
170+
3. Save and commit the changes
171+
172+
Once complete, this workflow will run any time a pull request is created or
173+
changes pushed directly to `main`. If the workflow detects any dependencies with
174+
missing or non-compliant licenses, it will fail the workflow and provide details
175+
on the issue(s) found.
176+
177+
### Updating Licenses
178+
179+
Whenever you install or update dependencies, you can use the Licensed CLI to
180+
update the licenses database. To install Licensed, see the project's
181+
[Readme](https://github.com/licensee/licensed?tab=readme-ov-file#installation).
182+
183+
To update the cached licenses, run the following command:
184+
185+
```bash
186+
licensed cache
187+
```
188+
189+
To check the status of cached licenses, run the following command:
190+
191+
```bash
192+
licensed status
193+
```

0 commit comments

Comments
 (0)