Skip to content

Refactor getVersionFromToolVersionsFile function #128

Refactor getVersionFromToolVersionsFile function

Refactor getVersionFromToolVersionsFile function #128

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- main
merge_group:
jobs:
test:
name: test ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: "Create bare bones Scarb.lock for cache testing"
shell: bash
run: |
cat <<EOF > Scarb.lock
# Code generated by scarb DO NOT EDIT.
version = 1
[[package]]
name = "example_package"
version = "1.0.0"
EOF
- name: "Create Scarb.lock in subfolder for cache testing"
shell: bash
run: |
mkdir ./subdir
cat <<EOF > ./subdir/Scarb.lock
# Code generated by scarb DO NOT EDIT.
version = 1
[[package]]
name = "example_package"
version = "1.1.0"
EOF
- name: "Fetch latest Scarb version from GitHub releases"
id: version
shell: pwsh
run: |
$location = (Invoke-WebRequest -Uri "https://github.com/software-mansion/scarb/releases/latest" -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction Ignore).Headers.Location
$latest_version = ($location -replace '^.*/v','')
echo "Latest Scarb version found is $latest_version"
echo "LATEST_VERSION=$latest_version" >> $env:GITHUB_OUTPUT
$location = (Invoke-WebRequest -Uri "https://github.com/software-mansion/scarb-nightlies/releases/latest" -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction Ignore).Headers.Location
$latest_version = ($location -replace '^.*/nightly-','nightly-')
echo "Latest Scarb nightly version found is $latest_version"
echo "LATEST_NIGHTLY_VERSION=$latest_version" >> $env:GITHUB_OUTPUT
- name: "Setup Scarb without `scarb-version`"
uses: ./
- run: scarb --version | grep "scarb ${{ steps.version.outputs.LATEST_VERSION }}"
# NOTE: This is Scarb <0.7.0, thus this test checks the `cache path` fallback logic.
- name: "Setup Scarb with `scarb-version: 0.4.1`"
uses: ./
with:
scarb-version: 0.4.1
- run: scarb --version | grep "scarb 0.4.1"
- name: "Setup Scarb with `scarb-version: latest`"
uses: ./
with:
scarb-version: latest
- run: scarb --version | grep "scarb ${{ steps.version.outputs.LATEST_VERSION }}"
- name: "Setup Scarb with `scarb-version: nightly-2023-08-10`"
uses: ./
with:
scarb-version: nightly-2023-08-10
- run: scarb --version | grep "scarb 0.6.0+nightly-2023-08-10"
- name: "Setup Scarb with `scarb-version: nightly`"
uses: ./
with:
scarb-version: nightly
- run: scarb --version | grep "${{ steps.version.outputs.LATEST_NIGHTLY_VERSION }}"
- name: "Setup Scarb with `scarb-lock` file in subfolder"
uses: ./
with:
scarb-lock: ./subdir/Scarb.lock
- name: "Create .tool-versions file"
run: echo "scarb 0.7.0" >> .tool-versions
- name: "Setup Scarb using `.tool-versions` file"
uses: ./
- run: scarb --version | grep "scarb 0.7.0"
- name: "Create .tool-versions file in subfolder"
run: mkdir ./tmp && echo "scarb 0.7.0" >> ./tmp/.tool-versions
- name: "Setup Scarb using `.tool-versions` file in subfolder"
uses: ./
with:
tool-versions: ./tmp/.tool-versions
- run: scarb --version | grep "scarb 0.7.0"
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
- run: npm ci
- run: npm run lint