Skip to content

Merge branch 'NNS1-3351-neuron-visibility-cell' of https://github.com… #31889

Merge branch 'NNS1-3351-neuron-visibility-cell' of https://github.com…

Merge branch 'NNS1-3351-neuron-visibility-cell' of https://github.com… #31889

Workflow file for this run

name: Unit Tests
on:
push:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -euxlo pipefail {0}
jobs:
formatting:
runs-on: ubuntu-20.04
env:
DFX_NETWORK: mainnet
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get cargo sort version
run: jq -r '"CARGO_SORT_VERSION=\(.defaults.build.config.CARGO_SORT_VERSION)"' dfx.json >> $GITHUB_ENV
- name: Get node version
run: jq -r '"NODE_VERSION=\(.defaults.build.config.NODE_VERSION)"' dfx.json >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install shfmt
run: sudo snap install --classic shfmt
- name: Install yq
run: sudo snap install yq
- name: Install cargo dependency sorter
run: cargo install cargo-sort@${{ env.CARGO_SORT_VERSION }}
- name: Format
run: ./scripts/fmt
- name: Check formatted
run: |
test -z "$(git status --porcelain)" || {
echo "FIX: Please run ./scripts/fmt"
git diff
exit 1
}
spelling:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install spellcheck
run: |
sudo apt-get update
sudo apt-get install -yy hunspell hunspell-en-gb hunspell-en-us clang libclang-dev
cargo install --locked --target x86_64-unknown-linux-gnu cargo-spellcheck@0.13.1
- name: Spellcheck Rust
run: cargo spellcheck --code 1
- name: Spellcheck changelog
run: scripts/spellcheck-changelog
cargo-tests:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1
- name: Lint rust code
run: ./scripts/lint-rs
- name: Run Unit Tests
shell: bash
run: |
RUSTFLAGS="-D warnings" cargo test --lib --bins --benches --examples --all-features
env:
RUST_BACKTRACE: 1
- name: Lint rustdoc
run: ./scripts/lint-rustdoc
svelte-tests:
runs-on: ubuntu-latest-m
defaults:
run:
shell: bash
env:
DFX_NETWORK: mainnet
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get node version
run: jq -r '"NODE_VERSION=\(.defaults.build.config.NODE_VERSION)"' dfx.json >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci
working-directory: ./frontend
- name: Test
run: npm run test
working-directory: ./frontend
svelte-lint:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
env:
DFX_NETWORK: mainnet
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get node version
run: jq -r '"NODE_VERSION=\(.defaults.build.config.NODE_VERSION)"' dfx.json >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci
working-directory: ./frontend
- name: Run linter
run: npm run check
working-directory: ./frontend
shell-checks:
name: ShellCheck
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
run: |
sudo apt-get update
sudo apt-get install -yy shellcheck
./scripts/lint-sh
ic-commit-consistency:
name: IC Commit
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install didc
run: scripts/install-didc
- name: Check didc
run: command -v didc
- name: Run the ic_commit code generator for proposals
run: |
./scripts/update_ic_commit --crate proposals --ic_commit "$(jq -re .defaults.build.config.IC_COMMIT_FOR_PROPOSALS dfx.json)"
./scripts/proposals/did2rs
- name: Run the ic_commit code generator for sns_aggregator
run: |
./scripts/update_ic_commit --crate sns_aggregator --ic_commit "$(jq -re .defaults.build.config.IC_COMMIT_FOR_SNS_AGGREGATOR dfx.json)"
./scripts/sns/aggregator/mk_nns_patch.sh
- name: Verify that there are no code changes
run: |
if git diff | grep . ; then
echo "ERROR: The code is not consistent with the IC_COMMIT in dfx.json"
echo "Note: didc version: $(didc --version)"
exit 1
fi
release-templating-works:
name: Release template
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install didc
run: scripts/install-didc
- name: Check didc
run: command -v didc
- name: Install dfx
uses: dfinity/setup-dfx@main
- name: Verify template creation
run: |
echo Create a fake wasm
mkdir -p release/ci
touch release/ci/nns-dapp.wasm.gz
echo Create a proposal template
scripts/nns-dapp/release-template
echo Check the proposal
./scripts/nns-dapp/release-check
config-check:
name: Config is as expected
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install dfx
uses: dfinity/setup-dfx@main
- name: Install cargo binstall
uses: ./.github/actions/install_binstall
- name: Install tools
run: |
cargo binstall --no-confirm "idl2json_cli@$(jq -r .defaults.build.config.IDL2JSON_VERSION dfx.json)"
- name: Check mainnet config
run: bash -x config.test
migration-test-utils-work:
name: Migration test utilities work
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install cargo binstall
uses: ./.github/actions/install_binstall
- name: Install idl2json
run: cargo binstall --no-confirm "idl2json_cli@$(jq -r .defaults.build.config.IDL2JSON_VERSION dfx.json)" && idl2json --version
- name: Test migration utilities
run: |
set +x
scripts/nns-dapp/migration-test.on-exit.test
dfx-nns-proposal-args-works:
# TODO: Re-enable (add it in line 338) once fixed, should it depend on mainnet?
if: false
name: Can get NNS proposal args
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install didc
run: scripts/install-didc
- name: Install cargo binstall
uses: ./.github/actions/install_binstall
- name: Install idl2json
run: cargo binstall --no-confirm "idl2json_cli@$(jq -r .defaults.build.config.IDL2JSON_VERSION dfx.json)" && idl2json --version
- name: Install sponge
run: sudo apt-get update -yy && sudo apt-get install -yy moreutils && command -v sponge
- name: Install dfx
uses: dfinity/setup-dfx@main
- name: Test getting proposal args
run: scripts/dfx-nns-proposal-args.test
minor-version-bump-works:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install yq
run: sudo snap install yq
- name: Install sponge
run: sudo apt-get update -yy && sudo apt-get install -yy moreutils && command -v sponge
- name: Get node version
run: jq -r '"NODE_VERSION=\(.defaults.build.config.NODE_VERSION)"' dfx.json >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Bumping the package versions works
run: ./scripts/nns-dapp/bump-patch.test
- name: Set git user
run: |
git config --global user.email "gix-bot@users.noreply.github.com"
git config --global user.name "GIX bot"
- name: Command creates commits
run: |
original_commit="$(git rev-parse HEAD)"
git checkout .
./scripts/nns-dapp/bump-patch --commit
num_commits="$(git log --oneline "$original_commit..HEAD" | wc -l)"
(( num_commits == 2 )) || {
echo "Expected two commits. Got:"
git log --oneline "$original_commit..HEAD"
exit 1
} >&2
# TODO: Verify that the commits contain the expected changes.
version-match:
name: The nns-dapp npm and cargo versions should match
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Backend and frontend have the same version
run: |
backend_version="$(cargo metadata | jq -r '.packages[] | select(.name == "nns-dapp").version')"
frontend_version="$(jq -r .version frontend/package.json)"
[[ "${backend_version}" == "${frontend_version}" ]] || {
echo "ERROR: The nns-dapp frontend and backend should have the same version but:"
echo "Backend: $backend_version"
echo "Frontend: $frontend_version"
exit 1
} >&2
small-tests:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-13]
runs-on: ${{ matrix.os }}
env:
# Used by download-ci-wasm.test
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
- name: Install tools on Linux
run: |
if command -v apt-get; then
# libarchive-zip-perl is needed for crc32, used by convert-id.test
sudo apt-get update -yy && sudo apt-get install -yy moreutils libarchive-zip-perl && command -v sponge
fi
- name: Install tools on Mac
run: |
if command -v brew ; then
# coreutils is needed for
# base32, used by convert-id.test, and
# sha256sum, used download-ci-wasm.test
# moreutils is needed for sponge, used by network-config.test
brew install bash coreutils moreutils
fi
- name: Install didc
run: |
scripts/install-didc
# `didc` is installed in $HOME/.local/bin, which is in the path by
# default on Linux but not on Mac.
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Ensure required didc version
run: ./scripts/ensure-required-didc-version.test
- name: docker-build prints help
run: ./scripts/docker-build --help | grep -i usage
- name: Download NNS-dapp CI wasm
run: |
MAIN_COMMIT="$(git ls-remote --refs https://github.com/dfinity/nns-dapp.git main | awk '{print $1}')"
scripts/nns-dapp/download-ci-wasm.test --commit "$MAIN_COMMIT"
- name: Test canister_ids tool
run: scripts/canister_ids.test
- name: Test release-sop script
run: scripts/nns-dapp/release-sop.test
- name: Test split-changelog script
run: scripts/nns-dapp/split-changelog.test
- name: Find unused i18n messages
run: scripts/unused-i18n
- name: Test the ID conversion script
run: scripts/convert-id.test
- name: Getting network config works
run: scripts/network-config.test
- name: Get SNS tool
run: |
diff <(scripts/sns/aggregator/get-sns dog) <(echo "Name: DOGMI
Symbol: DOGMI
Aggregator URL: https://3r4gx-wqaaa-aaaaq-aaaia-cai.icp0.io/v1/sns/root/nb7he-piaaa-aaaaq-aadqq-cai/slow.json
Root canister ID: nb7he-piaaa-aaaaq-aadqq-cai
Governance canister ID: ni4my-zaaaa-aaaaq-aadra-cai
Ledger canister ID: np5km-uyaaa-aaaaq-aadrq-cai
Index canister ID: n535v-yiaaa-aaaaq-aadsq-cai
Swap canister ID: n223b-vqaaa-aaaaq-aadsa-cai
Transaction fee: 50
Minimum neuron stake: 100
Proposal fee: 15000")
checks-pass:
needs:
- formatting
- spelling
- cargo-tests
- svelte-lint
- svelte-tests
- shell-checks
- ic-commit-consistency
- release-templating-works
- config-check
- minor-version-bump-works
- migration-test-utils-work
- version-match
- small-tests
if: ${{ always() }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/needs_success
with:
needs: '${{ toJson(needs) }}'