From c95133efc9271a304040c92e4d0c7ab845c4af52 Mon Sep 17 00:00:00 2001 From: Jeremy Bogle Date: Sat, 21 May 2022 15:06:59 -0700 Subject: [PATCH] Revert "Handle duration" --- api/img-generator/generator.ts | 25 ----- api/metadata-generator/generator.ts | 14 --- api/package.json | 11 +-- api/serverless.yml | 12 +-- api/yarn.lock | 125 ++++------------------- workflows/deps.yml | 41 ++++++++ workflows/publish-docs.yml | 54 ++++++++++ workflows/publish-js.yml | 93 +++++++++++++++++ workflows/release.yml | 148 ++++++++++++++++++++++++++++ workflows/test-dev.yml | 60 +++++++++++ workflows/test-soteria.yml | 46 +++++++++ workflows/test.yml | 143 +++++++++++++++++++++++++++ 12 files changed, 617 insertions(+), 155 deletions(-) create mode 100644 workflows/deps.yml create mode 100644 workflows/publish-docs.yml create mode 100644 workflows/publish-js.yml create mode 100644 workflows/release.yml create mode 100644 workflows/test-dev.yml create mode 100644 workflows/test-soteria.yml create mode 100644 workflows/test.yml diff --git a/api/img-generator/generator.ts b/api/img-generator/generator.ts index 727f7a1..4f91fdd 100755 --- a/api/img-generator/generator.ts +++ b/api/img-generator/generator.ts @@ -311,31 +311,6 @@ export async function getImage( bottomLeft += 0.075 * WIDTH; } - const durationSeconds = - tokenData.timeInvalidatorData?.parsed?.durationSeconds; - if (durationSeconds && durationSeconds.toNumber()) { - const dateTime = new Date( - (Date.now() / 1000 + durationSeconds.toNumber()) * 1000 - ); - bottomLeftCtx.font = `${0.055 * WIDTH}px SFPro`; - bottomLeftCtx.fillStyle = "white"; - bottomLeftCtx.fillText( - `${dateTime.toLocaleDateString(["en-US"], { - month: "2-digit", - day: "2-digit", - year: "2-digit", - })} ${dateTime.toLocaleTimeString(["en-US"], { - hour: "2-digit", - minute: "2-digit", - timeZone: "UTC", - timeZoneName: "short", - })}`, - PADDING, - HEIGHT - bottomLeft - ); - bottomLeft += 0.075 * WIDTH; - } - const usages = tokenData.useInvalidatorData?.parsed?.usages || tokenData?.certificateData?.parsed?.usages; diff --git a/api/metadata-generator/generator.ts b/api/metadata-generator/generator.ts index 5735102..7278f88 100755 --- a/api/metadata-generator/generator.ts +++ b/api/metadata-generator/generator.ts @@ -244,20 +244,6 @@ export async function getMetadata( }; } - if (tokenData.timeInvalidatorData?.parsed?.durationSeconds) { - response = { - ...response, - attributes: [ - ...(response.attributes || []), - { - trait_type: "duration", - value: `${tokenData.timeInvalidatorData?.parsed?.durationSeconds.toNumber()}`, - display_type: "Duration", - }, - ], - }; - } - // // certificate // if ( // tokenData.certificateData?.parsed.usages && diff --git a/api/package.json b/api/package.json index 09555f3..e59be52 100755 --- a/api/package.json +++ b/api/package.json @@ -18,15 +18,14 @@ "dependencies": { "@cardinal/certificates": "^1.2.6", "@cardinal/common": "^1.0.6", - "@cardinal/namespaces": "^3.0.32", + "@cardinal/namespaces": "=3.0.32", "@cardinal/quest-pool": "^1.1.3", "@cardinal/stake-pool": "^1.1.1", - "@cardinal/token-manager": "^1.3.10", + "@cardinal/token-manager": "=1.1.0", "@metaplex/js": "^4.2.1", - "@rushstack/eslint-patch": "^1.1.0", - "@project-serum/anchor": "^0.24.2", - "@saberhq/anchor-contrib": "^1.12.44", - "@saberhq/solana-contrib": "^1.12.44", + "@project-serum/anchor": "=0.21.0", + "@saberhq/anchor-contrib": "=1.12.48", + "@saberhq/solana-contrib": "^1.11", "@saberhq/token-utils": "^1.12.48", "@solana/spl-token": "^0.1.8", "bignumber.js": "^9.0.2", diff --git a/api/serverless.yml b/api/serverless.yml index 615f293..f641f15 100755 --- a/api/serverless.yml +++ b/api/serverless.yml @@ -52,14 +52,14 @@ custom: domainName: nft.cardinal.so dev: domainName: dev-nft.cardinal.so - # customDomain: - # domainName: ${self:custom.domains.${opt:stage}.domainName} - # certificateName: "*.cardinal.so" - # createRoute53Record: true - # autoDomain: true + customDomain: + domainName: ${self:custom.domains.${opt:stage}.domainName} + certificateName: "*.cardinal.so" + createRoute53Record: true + autoDomain: true plugins: - # - serverless-domain-manager + - serverless-domain-manager - serverless-apigw-binary - serverless-apigwy-binary - serverless-plugin-typescript diff --git a/api/yarn.lock b/api/yarn.lock index 366d8c8..97d5c5f 100644 --- a/api/yarn.lock +++ b/api/yarn.lock @@ -72,10 +72,10 @@ tiny-invariant "^1.2.0" tslib "^2.3.1" -"@cardinal/namespaces@^2.0.42": - version "2.0.59" - resolved "https://registry.yarnpkg.com/@cardinal/namespaces/-/namespaces-2.0.59.tgz#9e251c3a38f78faca58e208d1c5f2e10fa8c829b" - integrity sha512-2waZMfLyzAKi5y7bWBPzuqP/FDSjLS5u9VhsBLfEQbNOR3BHmHrSwrYPpAfV+IrULNBSSg8jobxoD5b94C3GEQ== +"@cardinal/namespaces@=3.0.32": + version "3.0.32" + resolved "https://registry.yarnpkg.com/@cardinal/namespaces/-/namespaces-3.0.32.tgz#b3f89694f70542a1dc89bff954029d783c782ee5" + integrity sha512-ZJrw3wxYfzJ3g2tmnqoesX5tTAfdXLHhr+Ix+SF91b16b5XZahb1YkTPc5rhwTa63D1OUwgqckuXHZ4zUVmziA== dependencies: "@cardinal/certificates" "^1.2.3" "@cardinal/namespaces" "^2.0.42" @@ -85,10 +85,10 @@ "@solana/spl-token" "^0.1.8" typescript "^4.5.4" -"@cardinal/namespaces@^3.0.32": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@cardinal/namespaces/-/namespaces-3.1.0.tgz#bee4acdf3d2bcf63aa5c02502f61fb8024ac4039" - integrity sha512-eX44mI0EFZrzvIHKGS/j0iUJPmCrl1av89jfSqWf6ldYYwLyENQysyOQv2az718pbJd9H5IQb+kJX0JLlQCo/w== +"@cardinal/namespaces@^2.0.42": + version "2.0.59" + resolved "https://registry.yarnpkg.com/@cardinal/namespaces/-/namespaces-2.0.59.tgz#9e251c3a38f78faca58e208d1c5f2e10fa8c829b" + integrity sha512-2waZMfLyzAKi5y7bWBPzuqP/FDSjLS5u9VhsBLfEQbNOR3BHmHrSwrYPpAfV+IrULNBSSg8jobxoD5b94C3GEQ== dependencies: "@cardinal/certificates" "^1.2.3" "@cardinal/namespaces" "^2.0.42" @@ -132,17 +132,16 @@ ts-mocha "^8.0.0" typescript "^4.5.5" -"@cardinal/token-manager@^1.3.10": - version "1.3.10" - resolved "https://registry.yarnpkg.com/@cardinal/token-manager/-/token-manager-1.3.10.tgz#f8e0bc23f80fb2d8479394837d6feccbabc3e904" - integrity sha512-yMG32kl+JKvvtCUmQ+ZE/WMk5hMq1gy1AVr7SMb9wTbAFoJmKuen/MBbF8IuGn3sjzqn/EIirbW6h+LlCAtqgw== +"@cardinal/token-manager@=1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@cardinal/token-manager/-/token-manager-1.1.0.tgz#5c64e2cdeaea0e7455ebca96f3d86180dc5c45e4" + integrity sha512-632KWT2fSB+3s/+vc5RCiFXPLjvUbnaFS/0NMa9h7dlZ7gVG1pV2A8ICv+IAhMAAN4jTt+Lr4d6M6244mlWRTg== dependencies: "@metaplex-foundation/mpl-token-metadata" "^1.2.3" "@solana/buffer-layout" "^4.0.0" "@solana/spl-token" "^0.1.8" borsh "^0.7.0" bs58 "^4.0.1" - superstruct "^0.15.4" tiny-invariant "^1.2.0" tslib "^2.3.1" @@ -642,7 +641,7 @@ snake-case "^3.0.4" toml "^3.0.0" -"@project-serum/anchor@0.21.0": +"@project-serum/anchor@0.21.0", "@project-serum/anchor@=0.21.0": version "0.21.0" resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.21.0.tgz#ad5fb33744991ec1900cdb2fd22707c908b12b5f" integrity sha512-flRuW/F+iC8mitNokx82LOXyND7Dyk6n5UUPJpQv/+NfySFrNFlzuQZaBZJ4CG5g9s8HS/uaaIz1nVkDR8V/QA== @@ -684,26 +683,6 @@ snake-case "^3.0.4" toml "^3.0.0" -"@project-serum/anchor@^0.24.2": - version "0.24.2" - resolved "https://registry.yarnpkg.com/@project-serum/anchor/-/anchor-0.24.2.tgz#a3c52a99605c80735f446ca9b3a4885034731004" - integrity sha512-0/718g8/DnEuwAidUwh5wLYphUYXhUbiClkuRNhvNoa+1Y8a4g2tJyxoae+emV+PG/Gikd/QUBNMkIcimiIRTA== - dependencies: - "@project-serum/borsh" "^0.2.5" - "@solana/web3.js" "^1.36.0" - base64-js "^1.5.1" - bn.js "^5.1.2" - bs58 "^4.0.1" - buffer-layout "^1.2.2" - camelcase "^5.3.1" - cross-fetch "^3.1.5" - crypto-hash "^1.3.0" - eventemitter3 "^4.0.7" - js-sha256 "^0.9.0" - pako "^2.0.3" - snake-case "^3.0.4" - toml "^3.0.0" - "@project-serum/borsh@^0.2.2", "@project-serum/borsh@^0.2.4", "@project-serum/borsh@^0.2.5": version "0.2.5" resolved "https://registry.yarnpkg.com/@project-serum/borsh/-/borsh-0.2.5.tgz#6059287aa624ecebbfc0edd35e4c28ff987d8663" @@ -765,21 +744,16 @@ resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= -"@rushstack/eslint-patch@^1.1.0": - version "1.1.3" - resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.1.3.tgz#6801033be7ff87a6b7cadaf5b337c9f366a3c4b0" - integrity sha512-WiBSI6JBIhC6LRIsB2Kwh8DsGTlbBU+mLRxJmAe3LjHTdkDpwIbEOZgoXBbZilk/vlfjK8i6nKRAvIRn1XaIMw== - -"@saberhq/anchor-contrib@^1.12.44": - version "1.13.15" - resolved "https://registry.yarnpkg.com/@saberhq/anchor-contrib/-/anchor-contrib-1.13.15.tgz#d45906deb196bfae70f23960d98b86d120710769" - integrity sha512-/n9cP7CiUr8g9h1TQXI/S+lfpD8efVEZFmqqF0LtWfLb6zNoOR+WQ9AMcl+XD+sz1pcsbUh0ncZIIma7uC3Q1w== +"@saberhq/anchor-contrib@=1.12.48": + version "1.12.48" + resolved "https://registry.yarnpkg.com/@saberhq/anchor-contrib/-/anchor-contrib-1.12.48.tgz#76f577df2fd3405086c80f2b9d7b30ca91e2ace0" + integrity sha512-UPITsnMazZXfCv4rI3Zx5aAxXZc2wPX09j2Bf5M6zVT1wYTbTEGp0yNLY4f926LBda+EngMkc19SrOYu94ODfw== dependencies: - "@saberhq/solana-contrib" "^1.13.15" + "@saberhq/solana-contrib" "^1.12.48" eventemitter3 "^4.0.7" lodash.camelcase "^4.3.0" lodash.mapvalues "^4.6.0" - tslib "^2.4.0" + tslib "^2.3.1" "@saberhq/anchor-contrib@^1.12.47", "@saberhq/anchor-contrib@^1.12.48": version "1.12.66" @@ -792,7 +766,7 @@ lodash.mapvalues "^4.6.0" tslib "^2.4.0" -"@saberhq/solana-contrib@^1.12.23", "@saberhq/solana-contrib@^1.12.47", "@saberhq/solana-contrib@^1.12.48", "@saberhq/solana-contrib@^1.12.66": +"@saberhq/solana-contrib@^1.11", "@saberhq/solana-contrib@^1.12.23", "@saberhq/solana-contrib@^1.12.47", "@saberhq/solana-contrib@^1.12.48", "@saberhq/solana-contrib@^1.12.66": version "1.12.66" resolved "https://registry.yarnpkg.com/@saberhq/solana-contrib/-/solana-contrib-1.12.66.tgz#19677f54fe56f4d02ad1bf75749d6e14e673f309" integrity sha512-rFivOXpx5TaFv7JrPA/uhwA9TmPfMym4SY/WP3OZROXO7eh0+JLlecFvy3kkh0mnbM7LPcmQUUPPJ16Ox9+vKA== @@ -805,19 +779,6 @@ tiny-invariant "^1.2.0" tslib "^2.4.0" -"@saberhq/solana-contrib@^1.12.44", "@saberhq/solana-contrib@^1.13.15": - version "1.13.15" - resolved "https://registry.yarnpkg.com/@saberhq/solana-contrib/-/solana-contrib-1.13.15.tgz#e5d9a86b6b2b9fdce3eca05eae00f39e0295307a" - integrity sha512-4IldAgysqQCuiq38DZzld3x1qVv7Jp4WJJ8vv/xPHh3DXeOiWxAtvgqd+aHAFOzyoCRLa9TG2wx21YOrQ/YIxw== - dependencies: - "@solana/buffer-layout" "^4.0.0" - "@types/promise-retry" "^1.1.3" - "@types/retry" "^0.12.2" - promise-retry "^2.0.1" - retry "^0.13.1" - tiny-invariant "^1.2.0" - tslib "^2.4.0" - "@saberhq/token-utils@^1.12.48": version "1.12.66" resolved "https://registry.yarnpkg.com/@saberhq/token-utils/-/token-utils-1.12.66.tgz#35bedfe728c2722c006716c77e4faf512c9915a7" @@ -1119,28 +1080,6 @@ superstruct "^0.14.2" tweetnacl "^1.0.0" -"@solana/web3.js@^1.36.0": - version "1.43.1" - resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.43.1.tgz#f0cfffe7feb798563440f9ca0b0e9ba099e13967" - integrity sha512-s6TRcWz3rYvxM8gg1eQmUAUJQeoXIFMG9MbSWb/uRrLU0q7Xd9Ic1PNbACp1n1O0wyCogTAyFWXXPK476aIVSg== - dependencies: - "@babel/runtime" "^7.12.5" - "@ethersproject/sha2" "^5.5.0" - "@solana/buffer-layout" "^4.0.0" - bigint-buffer "^1.1.5" - bn.js "^5.0.0" - borsh "^0.7.0" - bs58 "^4.0.1" - buffer "6.0.1" - cross-fetch "^3.1.4" - fast-stable-stringify "^1.0.0" - jayson "^3.4.4" - js-sha3 "^0.8.0" - rpc-websockets "^7.4.2" - secp256k1 "^4.0.2" - superstruct "^0.14.2" - tweetnacl "^1.0.0" - "@szmarczak/http-timer@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421" @@ -1340,11 +1279,6 @@ resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.1.tgz#d8f1c0d0dc23afad6dc16a9e993a0865774b4065" integrity sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g== -"@types/retry@^0.12.2": - version "0.12.2" - resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.2.tgz#ed279a64fa438bb69f2480eda44937912bb7480a" - integrity sha512-XISRgDJ2Tc5q4TRqvgJtzsRkFYNJzZrhTdtMoGVBttwzzQJkPnS3WWTFc7kuDRoPtPakl+T+OfdEUjYJj7Jbow== - "@types/ws@^7.4.4": version "7.4.7" resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.7.tgz#f7c390a36f7a0679aa69de2d501319f4f8d9b702" @@ -1736,13 +1670,6 @@ big.js@^6.1.1: resolved "https://registry.yarnpkg.com/big.js/-/big.js-6.1.1.tgz#63b35b19dc9775c94991ee5db7694880655d5537" integrity sha512-1vObw81a8ylZO5ePrtMay0n018TcftpTA5HFKDaSuiUDBo8biRBtjIobw60OpwuvrGk+FsxKamqN4cnmj/eXdg== -bigint-buffer@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/bigint-buffer/-/bigint-buffer-1.1.5.tgz#d038f31c8e4534c1f8d0015209bf34b4fa6dd442" - integrity sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA== - dependencies: - bindings "^1.3.0" - bignumber.js@^9.0.2: version "9.0.2" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.2.tgz#71c6c6bed38de64e24a65ebe16cfcf23ae693673" @@ -1761,7 +1688,7 @@ binary@~0.3.0: buffers "~0.1.1" chainsaw "~0.1.0" -bindings@^1.3.0, bindings@^1.3.1: +bindings@^1.3.1: version "1.5.0" resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== @@ -3231,11 +3158,6 @@ fast-levenshtein@~2.0.6: resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= -fast-stable-stringify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz#5c5543462b22aeeefd36d05b34e51c78cb86d313" - integrity sha1-XFVDRisiru79NtBbNOUceMuG0xM= - fastest-levenshtein@^1.0.12: version "1.0.12" resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz#9990f7d3a88cc5a9ffd1f1745745251700d497e2" @@ -6678,11 +6600,6 @@ superstruct@^0.14.2: resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.14.2.tgz#0dbcdf3d83676588828f1cf5ed35cda02f59025b" integrity sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ== -superstruct@^0.15.4: - version "0.15.4" - resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.15.4.tgz#e3381dd84ca07e704e19f69eda74eee1a5efb1f9" - integrity sha512-eOoMeSbP9ZJChNOm/9RYjE+F36rYR966AAqeG3xhQB02j2sfAUXDp4EQ/7bAOqnlJnuFDB8yvOu50SocvKpUEw== - supports-color@8.1.1, supports-color@^8.1.1: version "8.1.1" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" diff --git a/workflows/deps.yml b/workflows/deps.yml new file mode 100644 index 0000000..3ebd89e --- /dev/null +++ b/workflows/deps.yml @@ -0,0 +1,41 @@ +name: Deps + +on: + workflow_dispatch: {} + +env: + CARGO_TERM_COLOR: always + SOLANA_VERSION: 1.9.13 + ANCHOR_GIT: https://github.com/project-serum/anchor + RUST_TOOLCHAIN: nightly + NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + +jobs: + test: + runs-on: ubuntu-latest + name: Build deps and cache + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/install-linux-build-deps + - name: Install Rust nightly + uses: actions-rs/toolchain@v1 + with: + override: true + profile: minimal + toolchain: ${{ env.RUST_TOOLCHAIN }} + - uses: ./.github/actions/install-solana + with: + solana_version: ${{ env.SOLANA_VERSION }} + - uses: ./.github/actions/install-anchor + with: + anchor_git: ${{ env.ANCHOR_GIT }} + + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ./rust/target + key: ${{ env.cache_id }}-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUSTC_HASH }} diff --git a/workflows/publish-docs.yml b/workflows/publish-docs.yml new file mode 100644 index 0000000..0aed190 --- /dev/null +++ b/workflows/publish-docs.yml @@ -0,0 +1,54 @@ +name: Publish docs + +on: + workflow_dispatch: {} + push: + branches: [main] + +env: + CARGO_TERM_COLOR: always + RUST_TOOLCHAIN: nightly + NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + +jobs: + site: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v16 + with: + install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install + install_options: "--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve" + extra_nix_config: | + experimental-features = nix-command flakes + - name: Setup Cachix + uses: cachix/cachix-action@v10 + with: + name: cardinal-staking + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn config get cacheFolder)" + - name: Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-modules- + + - name: Install Yarn dependencies + run: yarn install + # - name: Parse IDLs + # run: nix shell .#ci --command yarn idl:generate + - run: yarn docs:generate + - run: cp -R images/ site/ + + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@v4.2.5 + with: + branch: gh-pages + folder: site diff --git a/workflows/publish-js.yml b/workflows/publish-js.yml new file mode 100644 index 0000000..a94413a --- /dev/null +++ b/workflows/publish-js.yml @@ -0,0 +1,93 @@ +name: Publish JS + +on: + workflow_dispatch: {} + push: + tags: + - "js-v*.*.*" + +env: + CARGO_TERM_COLOR: always + RUST_TOOLCHAIN: nightly + NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + +jobs: + release-sdk: + runs-on: ubuntu-latest + name: Release SDK on NPM + steps: + - uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v16 + with: + install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install + install_options: "--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve" + extra_nix_config: | + experimental-features = nix-command flakes + - name: Setup Cachix + uses: cachix/cachix-action@v10 + with: + name: cardinal-staking + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn config get cacheFolder)" + - name: Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-modules- + + - name: Install Yarn dependencies + run: yarn install + - name: Parse IDLs + run: nix shell .#ci --command yarn idl:generate + - run: yarn build + - run: | + echo 'npmAuthToken: "${NPM_AUTH_TOKEN}"' >> .yarnrc.yml + - name: Publish + run: yarn npm publish + site: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v16 + with: + install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install + install_options: "--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve" + extra_nix_config: | + experimental-features = nix-command flakes + - name: Setup Cachix + uses: cachix/cachix-action@v10 + with: + name: cardinal-staking + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn config get cacheFolder)" + - name: Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-modules- + + - name: Install Yarn dependencies + run: yarn install + # - name: Parse IDLs + # run: nix shell .#ci --command yarn idl:generate + - run: yarn docs:generate + - run: cp -R images/ site/ + + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@v4.2.5 + with: + branch: gh-pages + folder: site diff --git a/workflows/release.yml b/workflows/release.yml new file mode 100644 index 0000000..7ef6c4d --- /dev/null +++ b/workflows/release.yml @@ -0,0 +1,148 @@ +name: Release + +on: + workflow_dispatch: {} + push: + tags: + - "v*.*.*" + +env: + CARGO_TERM_COLOR: always + RUST_TOOLCHAIN: nightly + NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + +jobs: + release-sdk: + runs-on: ubuntu-latest + name: Release SDK on NPM + steps: + - uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v16 + with: + install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install + install_options: "--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve" + extra_nix_config: | + experimental-features = nix-command flakes + - name: Setup Cachix + uses: cachix/cachix-action@v10 + with: + name: cardinal-staking + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn config get cacheFolder)" + - name: Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-modules- + + - name: Install Yarn dependencies + run: yarn install + - name: Parse IDLs + run: nix shell .#ci --command yarn idl:generate + - run: yarn build + - run: | + echo 'npmAuthToken: "${NPM_AUTH_TOKEN}"' >> .yarnrc.yml + - name: Publish + run: yarn npm publish + + release-crate: + runs-on: ubuntu-latest + name: Release crate on crates.io + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v16 + with: + install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install + install_options: "--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve" + extra_nix_config: | + experimental-features = nix-command flakes + - name: Setup Cachix + uses: cachix/cachix-action@v10 + with: + name: cardinal-staking + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Install Rust nightly + uses: actions-rs/toolchain@v1 + with: + override: true + profile: minimal + toolchain: ${{ env.RUST_TOOLCHAIN }} + - uses: Swatinem/rust-cache@v1 + - name: Publish crates + run: nix shell .#ci --command cargo workspaces publish --from-git --yes --skip-published --token ${{ secrets.CARGO_PUBLISH_TOKEN }} + + release-binaries: + runs-on: ubuntu-latest + name: Release verifiable binaries + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v16 + with: + install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install + install_options: "--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve" + extra_nix_config: | + experimental-features = nix-command flakes + - name: Setup Cachix + uses: cachix/cachix-action@v10 + with: + name: cardinal-staking + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Build programs + run: nix shell .#ci --command anchor build --verifiable + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: | + target/deploy/* + target/idl/* + target/verifiable/* + + site: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v16 + with: + install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install + install_options: "--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve" + extra_nix_config: | + experimental-features = nix-command flakes + - name: Setup Cachix + uses: cachix/cachix-action@v10 + with: + name: cardinal-staking + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn config get cacheFolder)" + - name: Yarn Cache + uses: actions/cache@v3 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-modules- + + - name: Install Yarn dependencies + run: yarn install + # - name: Parse IDLs + # run: nix shell .#ci --command yarn idl:generate + - run: yarn docs:generate + - run: cp -R images/ site/ + + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@v4.2.5 + with: + branch: gh-pages + folder: site diff --git a/workflows/test-dev.yml b/workflows/test-dev.yml new file mode 100644 index 0000000..5cdc05b --- /dev/null +++ b/workflows/test-dev.yml @@ -0,0 +1,60 @@ +name: Test dev + +on: + workflow_dispatch: {} + # push: + # branches: [main] + # pull_request: + # branches: [main] + +env: + CARGO_TERM_COLOR: always + SOLANA_VERSION: 1.9.13 + ANCHOR_GIT: https://github.com/project-serum/anchor + RUST_TOOLCHAIN: nightly + NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + +jobs: + test: + runs-on: ubuntu-latest + name: Publish devnet test results + steps: + - uses: actions/checkout@v3 + + - uses: ./.github/actions/install-linux-build-deps + - name: Install Rust nightly + uses: actions-rs/toolchain@v1 + with: + override: true + profile: minimal + toolchain: ${{ env.RUST_TOOLCHAIN }} + - uses: ./.github/actions/install-solana + with: + solana_version: ${{ env.SOLANA_VERSION }} + - uses: ./.github/actions/install-anchor + with: + anchor_git: ${{ env.ANCHOR_GIT }} + + # Restore Cache from previous build/test + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ./rust/target + key: ${{ env.cache_id }}-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUSTC_HASH }} + + - name: Install Yarn dependencies + run: yarn install + - run: solana airdrop 2 twLqUrEvBPdtWFusa4MSWqkyE7TyhJTv3xBXiLYUNcX --url https://api.devnet.solana.com + - run: anchor test --skip-local-validator --skip-build --skip-deploy --provider.cluster devnet + + - uses: dorny/test-reporter@v1 + if: always() + with: + artifact: test-results + name: Local Tests + path: "tests/out.json" + reporter: mocha-json diff --git a/workflows/test-soteria.yml b/workflows/test-soteria.yml new file mode 100644 index 0000000..b74b951 --- /dev/null +++ b/workflows/test-soteria.yml @@ -0,0 +1,46 @@ +name: Test soteria + +on: + workflow_dispatch: {} + +permissions: + checks: write + contents: read + issues: read + pull-requests: write + +env: + CARGO_TERM_COLOR: always + SOLANA_VERSION: 1.9.13 + ANCHOR_GIT: https://github.com/project-serum/anchor + RUST_TOOLCHAIN: nightly + SOTERIA_VERSION: 0.0.0 + +jobs: + soteria-scan: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + override: true + profile: minimal + toolchain: ${{ env.RUST_TOOLCHAIN }} + - uses: ./.github/actions/install-solana + with: + solana_version: ${{ env.SOLANA_VERSION }} + - uses: ./.github/actions/install-soteria + with: + soteria_version: ${{ env.SOTERIA_VERSION }} + - name: Soteria scan programs + working-directory: ./programs + run: >- + for PROGRAM in ./*; do + if [ -d "$PROGRAM" ]; then + cd "$PROGRAM" + echo "Soteria scan for $PROGRAM" + soteria -analyzeAll . + cd .. + fi + done + shell: bash diff --git a/workflows/test.yml b/workflows/test.yml new file mode 100644 index 0000000..b87f055 --- /dev/null +++ b/workflows/test.yml @@ -0,0 +1,143 @@ +name: Test + +on: + workflow_dispatch: {} + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + checks: write + contents: read + issues: read + pull-requests: write + +env: + CARGO_TERM_COLOR: always + SOLANA_VERSION: 1.9.13 + ANCHOR_GIT: https://github.com/project-serum/anchor + RUST_TOOLCHAIN: nightly + SOTERIA_VERSION: 0.0.0 + +jobs: + rust-clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + override: true + components: rustfmt, clippy + profile: minimal + toolchain: ${{ env.RUST_TOOLCHAIN }} + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + toolchain: ${{ env.RUST_TOOLCHAIN }} + args: --all-features + + rust-fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + override: true + components: rustfmt, clippy + profile: minimal + toolchain: ${{ env.RUST_TOOLCHAIN }} + - name: Run fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all --manifest-path ./Cargo.toml -- --check + + soteria-scan: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + override: true + profile: minimal + toolchain: ${{ env.RUST_TOOLCHAIN }} + - uses: ./.github/actions/install-solana + with: + solana_version: ${{ env.SOLANA_VERSION }} + - uses: ./.github/actions/install-soteria + with: + soteria_version: ${{ env.SOTERIA_VERSION }} + - name: Soteria scan programs + working-directory: ./programs + run: >- + for PROGRAM in ./*; do + if [ -d "$PROGRAM" ]; then + cd "$PROGRAM" + echo "Soteria scan for $PROGRAM" + soteria -analyzeAll . + cd .. + fi + done + shell: bash + + integration-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/install-linux-build-deps + - uses: actions-rs/toolchain@v1 + with: + override: true + profile: minimal + toolchain: ${{ env.RUST_TOOLCHAIN }} + - uses: ./.github/actions/install-solana + with: + solana_version: ${{ env.SOLANA_VERSION }} + - uses: ./.github/actions/install-anchor + with: + anchor_git: ${{ env.ANCHOR_GIT }} + + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ./rust/target + key: ${{ env.cache_id }}-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUSTC_HASH }} + + - name: Install Yarn dependencies + run: yarn install + + - name: Setup + run: mkdir -p target/deploy + - run: cp -r tests/test-keypairs/* target/deploy + - run: find . -type f -name "*" -exec sed -i'' -e "s/genSsTXZaAGH1kRUe74TXzwuernqZhJksHvpXiAxBQT/$(solana-keygen pubkey tests/test-keypairs/cardinal_generator-keypair.json)/g" {} + + - run: find . -type f -name "Anchor.toml" -exec sed -i'' -e "s/yarn mocha tests\/\*.spec.ts/yarn mocha tests\/\*.spec.ts --reporter mocha-junit-reporter --reporter-options mochaFile=.\/tests\/out.xml/g" {} + + + - name: Run tests + run: solana-test-validator --url https://api.devnet.solana.com --clone metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s --clone PwDiXFxQsGra4sFFTT8r1QWRMd4vfumiWC1jfWNfdYT --reset & echo $$! > validator.PID + - run: sleep 6 + - run: solana airdrop 1000 $(solana-keygen pubkey tests/test-key.json) --url http://localhost:8899 + - run: anchor test --skip-local-validator --provider.cluster localnet + + # - uses: dorny/test-reporter@v1 + # if: always() + # with: + # artifact: test-results + # name: Local Tests + # path: tests/*.json + # reporter: mocha-json + - name: Upload Test Results + if: always() + uses: actions/upload-artifact@v2 + with: + name: Unit Test Results + path: tests/out.xml + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action/composite@v1 + if: always() + with: + files: tests/out.xml