Skip to content

Commit 84390a1

Browse files
Fix determining version (#32)
* Add `console.log` * Fix resolving scarb version * Change version in `Test local action` * Remove windows from os matrix * Remove running tests on windows * Run `npm run build` * Simplify `determineVersion` * Remove running tests on Windows * Fix variable name * Fix resolving scarb version * Another console.log * Update console.log * Update console.log * Add console.log * More logs * More logs * Logs * Refactor `action.yml` * Little changes * Fix `determineVersion` * Include USC setup * Add envs in `action.yml` * Code cleanup * Run `npm run build` * Remove console logs * Add console.log * Add test for fixed version * Little refactor for fixed version validation * Formatting * Temporarily change fixed version to make workflow fail * Refactor `Verify snforge version` * Restore correct version * Run `npm run build` * Refactor * Use `actions/checkout@v4` instead of v3 * Trigger CI * Temporarily change way, how `StarknetFoundryVersionInput` is determined * Formatting * Formatting * Revert "Formatting" This reverts commit 43da8b8. * Add `workflow_dispatch` * Trigger CI * Fix `checks.yml` * Fix `checks.yml` * Code cleanup * Restore previous logic in `determineVersion`
1 parent 62b6f7b commit 84390a1

File tree

5 files changed

+43
-20
lines changed

5 files changed

+43
-20
lines changed

.github/workflows/check-dist.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ubuntu-latest
2323

2424
steps:
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2626

2727
- name: Set Node.js 20.x
2828
uses: actions/setup-node@v3

.github/workflows/checks.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
lint:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- uses: actions/setup-node@v3
1818
with:
1919
node-version: 20.x
@@ -28,7 +28,7 @@ jobs:
2828
test-action:
2929
runs-on: ubuntu-latest
3030
steps:
31-
- uses: actions/checkout@v3
31+
- uses: actions/checkout@v4
3232

3333
- name: Get scarb version
3434
id: extractScarbVersion
@@ -61,7 +61,7 @@ jobs:
6161
test-action-with-tools-file:
6262
runs-on: ubuntu-latest
6363
steps:
64-
- uses: actions/checkout@v3
64+
- uses: actions/checkout@v4
6565

6666
- name: "Create .tool-versions file"
6767
shell: bash
@@ -75,3 +75,31 @@ jobs:
7575

7676
- run: snforge --version | grep "snforge 0.16.0"
7777
shell: bash
78+
79+
test-action-with-fixed-version:
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v4
83+
84+
- name: "Setup Scarb"
85+
uses: software-mansion/setup-scarb@v1
86+
with:
87+
scarb-version: 2.9.4
88+
89+
- name: "Setup foundry using fixed version"
90+
uses: ./
91+
with:
92+
starknet-foundry-version: 0.44.0
93+
94+
- name: Verify snforge version
95+
run: |
96+
EXPECTED="snforge 0.44.0"
97+
VERSION=$(snforge --version)
98+
99+
echo "Expected version: $EXPECTED"
100+
echo "Actual version: $VERSION"
101+
102+
if [[ "$VERSION" != "$EXPECTED" ]]; then
103+
echo "Version mismatch"
104+
exit 1
105+
fi

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ runs:
2525
- name: Set up Starknet Foundry
2626
shell: bash
2727
run: node $GITHUB_ACTION_PATH/dist/index.js
28+
env:
29+
INPUT_STARKNET-FOUNDRY-VERSION: ${{ inputs.starknet-foundry-version }}
30+
INPUT_TOOL-VERSIONS: ${{ inputs.tool-versions }}

dist/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29824,12 +29824,12 @@ async function determineVersion(version, toolVersionsPath, repo) {
2982429824

2982529825
if (version && toolVersionsPath) {
2982629826
throw new Error(
29827-
"the `starknet-foundry-version` and `tool-versions` inputs cannot be used simultaneously",
29827+
"`starknet-foundry-version` and `tool-versions` inputs cannot be used simultaneously",
2982829828
);
2982929829
}
2983029830

2983129831
if (toolVersionsPath) {
29832-
let toolVersion = await getVersionFromToolVersionsFile(toolVersionsPath);
29832+
const toolVersion = await getVersionFromToolVersionsFile(toolVersionsPath);
2983329833

2983429834
if (!toolVersion) {
2983529835
throw new Error(
@@ -29840,19 +29840,15 @@ async function determineVersion(version, toolVersionsPath, repo) {
2984029840
}
2984129841

2984229842
if (!version) {
29843-
let toolVersion = await getVersionFromToolVersionsFile();
29843+
const toolVersion = await getVersionFromToolVersionsFile();
2984429844
version = toolVersion ?? "latest";
2984529845
}
2984629846

2984729847
if (version === "latest") {
2984829848
version = await fetchLatestTag(repo);
2984929849
}
2985029850

29851-
if (version.startsWith("v")) {
29852-
version = version.substring(1);
29853-
}
29854-
29855-
return version;
29851+
return version.startsWith("v") ? version.slice(1) : version;
2985629852
}
2985729853

2985829854
function fetchLatestTag(repo) {

lib/versions.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ export async function determineVersion(version, toolVersionsPath, repo) {
1919

2020
if (version && toolVersionsPath) {
2121
throw new Error(
22-
"the `starknet-foundry-version` and `tool-versions` inputs cannot be used simultaneously",
22+
"`starknet-foundry-version` and `tool-versions` inputs cannot be used simultaneously",
2323
);
2424
}
2525

2626
if (toolVersionsPath) {
27-
let toolVersion = await getVersionFromToolVersionsFile(toolVersionsPath);
27+
const toolVersion = await getVersionFromToolVersionsFile(toolVersionsPath);
2828

2929
if (!toolVersion) {
3030
throw new Error(
@@ -35,19 +35,15 @@ export async function determineVersion(version, toolVersionsPath, repo) {
3535
}
3636

3737
if (!version) {
38-
let toolVersion = await getVersionFromToolVersionsFile();
38+
const toolVersion = await getVersionFromToolVersionsFile();
3939
version = toolVersion ?? "latest";
4040
}
4141

4242
if (version === "latest") {
4343
version = await fetchLatestTag(repo);
4444
}
4545

46-
if (version.startsWith("v")) {
47-
version = version.substring(1);
48-
}
49-
50-
return version;
46+
return version.startsWith("v") ? version.slice(1) : version;
5147
}
5248

5349
function fetchLatestTag(repo) {

0 commit comments

Comments
 (0)