Skip to content

Commit

Permalink
Merge pull request #64 from algorandfoundation/beta-build
Browse files Browse the repository at this point in the history
Beta build
  • Loading branch information
tristanmenzel authored Dec 19, 2024
2 parents 54cd232 + 0426857 commit c9deda4
Show file tree
Hide file tree
Showing 674 changed files with 228,442 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[*]
charset = utf-8
insert_final_newline = true
end_of_line = lf
indent_style = space
indent_size = 2
tab_width = 2
max_line_length = 140
trim_trailing_whitespace = true
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Set the repository to show as TypeScript rather than JS in GitHub
*.js linguist-detectable=false

# Treat text as lf
* text=auto
* eol=lf
53 changes: 53 additions & 0 deletions .github/workflows/ci-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
on:
workflow_call:
inputs:
run-commit-lint:
required: false
type: boolean
default: false

jobs:
ci-algo-ts:
name: 'Build @algorandfoundation/algorand-typescript'
uses: ./.github/workflows/node-ci.yml
with:
node-version: 20.x
run-build: true
audit-script: npm run audit
working-directory: packages/algo-ts
upload-artifact-name: algo-ts
upload-artifact-path: ./packages/algo-ts/dist
post-build-script: |
cd dist
set +e # Continue on error
thisVersion=$(npm view ./ version)
diffText=$(npm diff --diff=./ --diff=@algorandfoundation/algorand-typescript@$thisVersion)
diffExitCode=$?
set -e # Exit on error
[ $diffExitCode -ne 0 ] && (echo "$thisVersion has not been published yet"; exit 0;) || echo "$thisVersion already published, checking diff against local build"
diffTextLen=${#diffText}
[ $diffTextLen -eq 0 ] && echo 'No changes' || (echo 'ERROR: Code differs to published version. Please bump package version or revert changes'; echo $diffText; exit 1;)
ci-puya-ts:
name: 'Build @algorandfoundation/puya-ts'
uses: ./.github/workflows/node-ci.yml
needs:
- ci-algo-ts
with:
download-artifact-pattern: algo-*
download-artifact-path: ./packages-temp
pre-run-script: mv packages-temp/algo-ts packages/algo-ts/dist
node-version: 20.x
run-build: true
run-commit-lint: ${{ inputs.run-commit-lint }}
build-script: npm run build
audit-script: npm run audit
upload-artifact-name: puya-ts
upload-artifact-path: ./dist
python-version: 3.12.6
pre-test-script: |
pipx install algokit --python 3.12.6
algokit localnet reset --update
pipx install git+https://github.com/algorandfoundation/puya --python 3.12.6
test-script: npm run test:ci
output-test-results: true
195 changes: 195 additions & 0 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
on:
workflow_call:
inputs:
node-version:
required: false
type: string
default: 18.x
python-version:
required: false
type: string
working-directory:
required: false
type: string
default: '.'
lint-script:
required: false
type: string
default: npm run lint --if-present
compile-script:
required: false
type: string
default: npm run check-types --if-present
pre-test-script:
required: false
type: string
test-script:
required: false
type: string
default: npm run test --if-present
test-environment-variables:
required: false
type: string
default: '{}'
output-test-results:
required: false
type: boolean
default: false
test-results-file-pattern:
required: false
type: string
default: '**/test-results.xml'
audit-script:
required: false
type: string
default: npm audit
build-script:
required: false
type: string
default: npm run build
post-build-script:
required: false
type: string
run-build:
required: false
type: boolean
default: false
run-commit-lint:
required: false
type: boolean
default: false
commit-lint-script:
required: false
type: string
default: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
pre-run-script:
required: false
type: string
upload-artifact-name:
required: false
type: string
upload-artifact-path:
required: false
description: The full path to the artifact directory, this path does not take working-directory into account
type: string
default: .

download-artifact-name:
required: false
type: string
download-artifact-pattern:
required: false
type: string
download-artifact-path:
required: false
description: The full path to the artifact directory, this path does not take working-directory into account
type: string
default: .

secrets:
npm-auth-token:
description: NPM auth token (don't pass in on a PR build on a public repository)
required: false

jobs:
node-ci:
runs-on: ubuntu-latest

defaults:
run:
shell: bash
working-directory: ${{ inputs.working-directory }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

# setup node + private repo access
- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
registry-url: 'https://npm.pkg.github.com'
scope: '@makerxstudio'
cache: 'npm'
cache-dependency-path: ${{ inputs.working-directory }}/package-lock.json

- name: Set up Python
if: ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Download artifacts
if: ${{ inputs.download-artifact-name || inputs.download-artifact-pattern }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.download-artifact-name }}
pattern: ${{ inputs.download-artifact-pattern }}
path: ${{ inputs.download-artifact-path }}

- name: Pre-run
if: ${{ inputs.pre-run-script }}
run: ${{ inputs.pre-run-script }}

# run npm ci preventing script access to npm auth token
- run: npm ci --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.npm-auth-token || secrets.GITHUB_TOKEN }}
# allow scripts to run without npm auth token
- run: npm rebuild && npm run prepare --if-present

# run all the CI scripts
- name: 'Commit lint'
if: ${{ inputs.run-commit-lint }}
run: ${{ inputs.commit-lint-script }}

- name: Lint
run: ${{ inputs.lint-script }}

- name: Compile
run: ${{ inputs.compile-script }}

- name: Pre-test
if: ${{ inputs.pre-test-script }}
run: ${{ inputs.pre-test-script }}

- name: Test
run: ${{ inputs.test-script }}
env: ${{ fromJson(inputs.test-environment-variables) }}

#Requires permissions.checks: write
- name: Publish test results
if: ${{ inputs.output-test-results && always() }}
uses: phoenix-actions/test-reporting@v10
with:
name: Test results
path: ${{ inputs.test-results-file-pattern }}
reporter: jest-junit
output-to: checks
fail-on-error: false

- name: Audit
run: ${{ inputs.audit-script }}

- name: Build
if: ${{ inputs.run-build }}
run: ${{ inputs.build-script }}
# CDK infrastructure build calls npm ci on /infrastructure/build, which may fail without NODE_AUTH_TOKEN
env:
NODE_AUTH_TOKEN: ${{ secrets.npm-auth-token || secrets.GITHUB_TOKEN }}

- name: Post build
if: ${{ inputs.post-build-script }}
run: ${{ inputs.post-build-script }}

- name: Publish artifact
if: ${{ inputs.upload-artifact-name }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.upload-artifact-name }}
path: ${{ inputs.upload-artifact-path }}


22 changes: 22 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Pull Request

on:
pull_request:
branches:
- main
- alpha
paths-ignore:
- 'docs/**'
- 'scripts/**'


permissions:
contents: read
checks: write

jobs:
ci-all:
name: 'Build and test all packages'
uses: ./.github/workflows/ci-all.yml
with:
run-commit-lint: true
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Publish

on:
push:
branches:
- alpha
- main
- release
workflow_dispatch:

concurrency: release

permissions:
contents: write
issues: write
pull-requests: write
checks: write

jobs:
ci:
name: Build and test
uses: ./.github/workflows/ci-all.yml
with:
run-commit-lint: false

release:
name: Release
needs: ci
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x

- run: npm ci --ignore-scripts

- name: Download package artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Publish @algorandfoundation/algorand-typescript
uses: JS-DevTools/npm-publish@v3
id: publish-algo-ts
with:
token: ${{ secrets.NPM_TOKEN }}
package: artifacts/algo-ts/package.json
access: 'public'

- name: Install @algorandfoundation/puya-ts dependencies and patch for bundling
run: npm i --include=prod && npx patch-package --patch-dir ../../patches
working-directory: artifacts/puya-ts

- name: Generate semantic version for @algorandfoundation/puya-ts
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish @algorandfoundation/puya-ts
uses: JS-DevTools/npm-publish@v3
id: publish-puya-ts
with:
token: ${{ secrets.NPM_TOKEN }}
package: artifacts/puya-ts/package.json
access: 'public'
Loading

0 comments on commit c9deda4

Please sign in to comment.