Skip to content

feat(ci): do not download the published npm version of Tact in CI #2740

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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ runs:
shell: bash
run: |
yarn clean
${{ runner.os != 'Windows' && 'time ' || '' }} yarn cross-env BUILD_THREADS=4 yarn gen
yarn cross-env BUILD_THREADS=4 yarn gen
yarn build

- name: Test Tact compiler
Expand Down
127 changes: 80 additions & 47 deletions .github/workflows/tact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
# Install dependencies, gen and build the compiler
yarn install
yarn clean
${{ matrix.os != 'windows-latest' && 'time ' || '' }} yarn cross-env BUILD_THREADS=4 yarn gen
yarn cross-env BUILD_THREADS=4 yarn gen
yarn build
# Test some specific things for backwards compatibility.
# It's important to restrain from using too much of Node.js 22+ features
Expand Down Expand Up @@ -84,45 +84,34 @@ jobs:
fail-fast: false
matrix:
node-version: [22]
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/test
- name: Test compatibility with tact-template
run: |
# !!!!!!! Don't forget to update test-windows below !!!!!!!
# NOTE:
# The ${{}} here and elsewhere is a templating syntax that allows injecting strings
# into the code of the resulting action. This is handy for keeping workflows together
# and using their default shells (PowerShell on Windows, Bash/Zsh elsewhere)
#
# Making PowerShell fail on errors
${{ matrix.os != 'windows-latest' && '$ErrorActionPreference = "Stop"' || '' }}
git clone https://github.com/tact-lang/tact-template.git
cd tact-template
# Hijack the dependency on Tact to avoid redundant npm downloads
jq 'del(.dependencies."@tact-lang/compiler")' package.json -M > temp.json
mv temp.json package.json
yarn install
# Hijacking the dependency on Tact to avoid redundant npm downloads
jq 'del(.dependencies."@tact-lang/compiler")' package.json ${{
matrix.os == 'windows-latest' # this template allows to adjust a part of the command
&& '-M | Set-Content'
|| '>' }} temp.json
${{
matrix.os == 'windows-latest'
&& 'Move-Item -Force temp.json package.json' # this will be executed on Windows
|| 'mv -f temp.json package.json' # and this — elsewhere
}}
yarn link @tact-lang/compiler
yarn build
yarn test

test-windows:
strategy:
fail-fast: false
matrix:
node-version: [22]
os: [windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/test
- name: Test compatibility with tact-template
run: |
# !!!!!!! Don't forget to update test above !!!!!!!
$ErrorActionPreference = 'Stop'
git clone https://github.com/tact-lang/tact-template.git
cd tact-template
# Hijack the dependency on Tact to avoid redundant npm downloads
jq 'del(.dependencies."@tact-lang/compiler")' package.json -M | Set-Content temp.json
Move-Item temp.json package.json -Force
yarn install
yarn link @tact-lang/compiler
yarn build
yarn test

Expand Down Expand Up @@ -162,18 +151,68 @@ jobs:
# corepack enable
yarn install
yarn clean
${{ matrix.os != 'windows-latest' && 'time ' || '' }} yarn cross-env BUILD_THREADS=4 yarn gen
yarn cross-env BUILD_THREADS=4 yarn gen
yarn build

- name: (npm) Test creation of new Blueprint projects
if: ${{ matrix.package-manager == 'npm' }}
- name: (${{ matrix.package-manager }}) Setup a new Blueprint project
run: |
npm link
# for end-users 'npm create ton@latest' works fine even in PowerShell,
# Linkage for npm, yarn, bun
${{ matrix.package-manager == 'npm' && 'npm link' || '' }}
${{ matrix.package-manager == 'yarn' && 'yarn link' || '' }}
${{ matrix.package-manager == 'bun' && 'bun link' || '' }}

# Create an empty Blueprint project
#
# The 'npm create ton@latest' command works fine even in PowerShell,
# but it fails on Windows in GitHub Actions because of weird -- expansion
npx create-ton@latest test-project --type tact-counter --contractName Counter
${{
matrix.package-manager == 'npm'
&& 'npx create-ton@latest test-project --no-ci'
|| ''
}}
${{
matrix.package-manager == 'yarn'
&& 'yarn create ton test-project --no-ci'
|| ''
}}
${{
matrix.package-manager == 'bun'
&& 'bun create ton@latest test-project --no-ci'
|| ''
}}

# Hijack dependencies on Tact to avoid redundant npm downloads
cd test-project
npm link @tact-lang/compiler
jq 'to_entries | map(if .value | type == "object" then .value |= del(."@tact-lang/compiler") else . end) | from_entries' package.json ${{
matrix.os == 'windows-latest'
&& '-M | Set-Content'
|| '>' }} temp.json
${{ matrix.os == 'windows-latest' && 'Move-Item -Force' || 'mv -f' }} temp.json package.json

# Setup the linkage to Tact compiler and install dependencies
${{
matrix.package-manager == 'npm'
&& 'npm link @tact-lang/compiler; npm install'
|| ''
}}
${{
matrix.package-manager == 'yarn'
&& 'yarn link @tact-lang/compiler; yarn install'
|| ''
}}
${{
matrix.package-manager == 'bun'
&& 'bun link @tact-lang/compiler; bun install'
|| ''
}}

# Create a new contract and all related facilities
${{ matrix.package-manager == 'bun' && 'bunx' || 'npx' }} blueprint create --type tact-counter Counter

- name: (npm) Test a new Blueprint project
if: ${{ matrix.package-manager == 'npm' }}
working-directory: "test-project"
run: |
npm run build
npm run test

Expand All @@ -187,22 +226,16 @@ jobs:
npm i ../ # installing compiler relatively
npm i @ton/blueprint

- name: (yarn) Test creation of new Blueprint projects
- name: (yarn) Test a new Blueprint project
if: ${{ matrix.package-manager == 'yarn' }}
working-directory: "test-project"
run: |
yarn link
yarn create ton test-project --type tact-counter --contractName Counter
cd test-project
yarn link @tact-lang/compiler
yarn build
yarn test

- name: (bun) Test creation of new Blueprint projects
- name: (bun) Test a new Blueprint project
if: ${{ matrix.package-manager == 'bun' }}
working-directory: "test-project"
run: |
bun link
bun create ton@latest test-project --type tact-counter --contractName Counter
cd test-project
bun link @tact-lang/compiler
bun run build # without 'run' Bun will use its own bundler
bun run test # without 'run' Bun will use its own test runner
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"spell": "yarn cspell --no-progress \"**\"",
"knip": "knip",
"lint:all": "yarn to-absolute && yarn gen:stdlib && yarn lint && yarn fmt:check:fast && yarn spell && yarn knip",
"all:fast": "yarn build:fast && yarn gen:contracts:fast && yarn test:fast && yarn lint:all",
"all": "yarn clean && yarn gen && yarn build && yarn coverage && yarn lint:all",
"next-version": "ts-node version.build.ts",
"random-ast": "ts-node ./src/ast/random-ast.infra.ts",
Expand Down