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

Use curl to download. #6

Merged
merged 2 commits into from
Jan 26, 2024
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
89 changes: 89 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: CI

on:
push:
branches:
- "*"
- "*/*"

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [v2.0.0-alpha.130, latest, ""]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup with version argument
id: setup1
if: ${{ matrix.version != '' }}
uses: ./
with:
toit-version: v2.0.0-alpha.130

- name: Setup without version argument
id: setup2
if: ${{ matrix.version == '' }}
uses: ./

- name: Test Toit in Path
shell: bash
run: |
toit.run --version
toit.pkg --version

- name: Test Toit in Path - native shell
run: |
toit.run --version
toit.pkg --version

- name: Test outputs
shell: bash
run: |
if [[ -z "${{ matrix.version }}" ]]; then
echo "No version argument"
TOIT_URL="${{ steps.setup2.outputs.toit-url }}"
TOIT_DIR="${{ steps.setup2.outputs.toit-install-dir }}"
TOIT_SDK="${{ steps.setup2.outputs.toit-sdk-path }}"
TOIT_VERSION="${{ steps.setup2.outputs.toit-version }}"
else
echo "With version argument"
TOIT_URL="${{ steps.setup1.outputs.toit-url }}"
TOIT_DIR="${{ steps.setup1.outputs.toit-install-dir }}"
TOIT_SDK="${{ steps.setup1.outputs.toit-sdk-path }}"
TOIT_VERSION="${{ steps.setup1.outputs.toit-version }}"
fi
if [[ "$TOIT_VERSION" == "" ]]; then
echo "No version"
exit 1
fi

if [[ "${{ matrix.version }}" != "latest" && "${{ matrix.version }}" != "" ]]; then
if [[ "$TOIT_VERSION" != "${{ matrix.version }}" ]]; then
echo "Version does not match"
exit 1
fi
fi

# The install-dir should have a toit directory.
if [[ ! -d "$TOIT_DIR/toit" ]]; then
echo "Install dir does not exist"
exit 1
fi

# The SDK-path is the toit directory.
if [[ "$TOIT_SDK" != "$TOIT_DIR/toit" ]]; then
echo "SDK path does not match install dir"
exit 1
fi

# The URL should be a valid URL.
if [[ ! "$TOIT_URL" =~ ^https://.* ]]; then
echo "URL is not a valid URL"
exit 1
fi
14 changes: 9 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ runs:
echo "UNSUPPORTED RUNNER: $RUNNER_OS"
exit 1
fi
echo "TOIT_FILE=$TOIT_FILE" >> $GITHUB_OUTPUT

if [[ $TOIT_VERSION = latest ]]; then
echo "TOIT_URL=https://github.com/toitlang/toit/releases/latest/download/$TOIT_FILE" >> $GITHUB_OUTPUT
else
Expand Down Expand Up @@ -72,10 +74,11 @@ runs:
echo TOIT_INSTALL_DIR=$TOIT_INSTALL_DIR >> $GITHUB_OUTPUT

- name: Download Toit
uses: suisei-cn/[email protected]
with:
url: ${{ steps.setup_constants.outputs.TOIT_URL }}
target: ${{ steps.tmp-dir.outputs.TOIT_INSTALL_DIR }}
shell: bash
run: |
cd '${{ steps.tmp-dir.outputs.TOIT_INSTALL_DIR }}'
# Downloads the tar.gz file.
curl -L -o ${{ steps.setup_constants.outputs.TOIT_FILE }} ${{ steps.setup_constants.outputs.TOIT_URL }}

- name: Extract Toit
shell: bash
Expand Down Expand Up @@ -103,4 +106,5 @@ runs:
shell: bash
run: |
cd '${{ steps.tmp-dir.outputs.TOIT_INSTALL_DIR }}'
echo "TOIT_VERSION=$(cat toit/VERSION)" >> $GITHUB_OUTPUT
# We use 'sed' as some version files had a trailing space.
echo "TOIT_VERSION=$(sed 's/ $//' toit/VERSION)" >> $GITHUB_OUTPUT