diff --git a/.github/actions/install_nim/action.yml b/.github/actions/install_nim/action.yml index 1bb49fcb8d..83de4f313a 100644 --- a/.github/actions/install_nim/action.yml +++ b/.github/actions/install_nim/action.yml @@ -61,7 +61,7 @@ runs: - name: Restore Nim DLLs dependencies (Windows) from cache if: inputs.os == 'Windows' id: windows-dlls-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: external/dlls key: 'dlls' @@ -114,7 +114,7 @@ runs: - name: Restore Nim from cache id: nim-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: '${{ github.workspace }}/nim' key: ${{ inputs.os }}-${{ inputs.cpu }}-nim-${{ inputs.nim_branch }}-cache-${{ env.cache_nonce }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 413dc56c7f..fcc8ed1cf8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,5 @@ -name: CI +name: Continuous Integration + on: push: branches: @@ -11,37 +12,41 @@ concurrency: cancel-in-progress: true jobs: - build: + test: timeout-minutes: 90 strategy: fail-fast: false matrix: - target: + platform: - os: linux cpu: amd64 - os: linux cpu: i386 - - os: ubuntu-24-gcc-14 + - os: linux-gcc-14 cpu: amd64 - os: macos cpu: amd64 - os: windows cpu: amd64 - branch: [version-1-6, version-2-0] + nim: + - branch: version-1-6 + memory_management: refc + - branch: version-2-0 + memory_management: refc include: - - target: + - platform: os: linux builder: ubuntu-22.04 shell: bash - - target: - os: ubuntu-24-gcc-14 + - platform: + os: linux-gcc-14 builder: ubuntu-24.04 shell: bash - - target: + - platform: os: macos builder: macos-13 shell: bash - - target: + - platform: os: windows builder: windows-2022 shell: msys2 {0} @@ -50,25 +55,24 @@ jobs: run: shell: ${{ matrix.shell }} - name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})' + name: '${{ matrix.platform.os }}-${{ matrix.platform.cpu }} (Nim ${{ matrix.nim.branch }})' runs-on: ${{ matrix.builder }} - continue-on-error: ${{ matrix.branch == 'devel' }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: true - name: Setup Nim uses: "./.github/actions/install_nim" with: - os: ${{ matrix.target.os }} - cpu: ${{ matrix.target.cpu }} + os: ${{ matrix.platform.os }} + cpu: ${{ matrix.platform.cpu }} shell: ${{ matrix.shell }} - nim_branch: ${{ matrix.branch }} + nim_branch: ${{ matrix.nim.branch }} - name: Setup Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: go-version: '~1.15.5' @@ -83,7 +87,7 @@ jobs: path: nimbledeps # Using nim.branch as a simple way to differentiate between nimble using the "pkgs" or "pkgs2" directories. # The change happened on Nimble v0.14.0. - key: nimbledeps-${{ matrix.branch }}-${{ hashFiles('.pinned') }} # hashFiles returns a different value on windows + key: nimbledeps-${{ matrix.nim.branch }}-${{ hashFiles('.pinned') }} # hashFiles returns a different value on windows - name: Install deps if: ${{ steps.deps-cache.outputs.cache-hit != 'true' }} @@ -91,7 +95,7 @@ jobs: nimble install_pinned - name: Use gcc 14 - if : ${{ matrix.target.os == 'ubuntu-24-gcc-14'}} + if : ${{ matrix.platform.os == 'linux-gcc-14'}} run: | # Add GCC-14 to alternatives sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 14 @@ -104,26 +108,5 @@ jobs: nim --version nimble --version gcc --version + NIMFLAGS="${NIMFLAGS} --mm:${{ matrix.nim.memory_management }}" nimble test - - lint: - name: "Lint" - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base - - - name: Check nph formatting - # Pin nph to a specific version to avoid sudden style differences. - # Updating nph version should be accompanied with running the new - # version on the fluffy directory. - run: | - VERSION="v0.5.1" - ARCHIVE="nph-linux_x64.tar.gz" - curl -L "https://github.com/arnetheduck/nph/releases/download/${VERSION}/${ARCHIVE}" -o ${ARCHIVE} - tar -xzf ${ARCHIVE} - shopt -s extglob # Enable extended globbing - ./nph examples libp2p tests tools *.@(nim|nims|nimble) - git diff --exit-code diff --git a/.github/workflows/codecov.yml b/.github/workflows/coverage.yml similarity index 79% rename from .github/workflows/codecov.yml rename to .github/workflows/coverage.yml index 3c43efacb8..062ed8fbcc 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/coverage.yml @@ -1,7 +1,7 @@ -name: nim-libp2p codecov builds +name: Coverage on: - #On push to common branches, this computes the "bases stats" for PRs + # On push to common branches, this computes the coverage that PRs will use for diff push: branches: - master @@ -13,12 +13,13 @@ concurrency: cancel-in-progress: true jobs: - Coverage: + codecov: + name: Run coverage and upload to codecov runs-on: ubuntu-22.04 env: CICOV: YES steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -31,7 +32,7 @@ jobs: - name: Restore deps from cache id: deps-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: nimbledeps key: nimbledeps-${{ hashFiles('.pinned') }} @@ -41,24 +42,28 @@ jobs: run: | nimble install_pinned - - name: Run + - name: Setup coverage run: | sudo apt-get update sudo apt-get install -y lcov build-essential git curl mkdir coverage + + - name: Run test suite with coverage flags + run: | export NIMFLAGS="--lineDir:on --passC:-fprofile-arcs --passC:-ftest-coverage --passL:-fprofile-arcs --passL:-ftest-coverage" nimble testnative nimble testpubsub nimble testfilter + + - name: Run coverage + run: | find nimcache -name *.c -delete lcov --capture --directory nimcache --output-file coverage/coverage.info shopt -s globstar ls `pwd`/libp2p/{*,**/*}.nim lcov --extract coverage/coverage.info `pwd`/libp2p/{*,**/*}.nim --output-file coverage/coverage.f.info genhtml coverage/coverage.f.info --output-directory coverage/output - bash <(curl -s https://codecov.io/bash) -f coverage/coverage.f.info || echo "Codecov did not collect coverage reports" - #- uses: actions/upload-artifact@master - # with: - # name: coverage - # path: coverage + - name: Upload coverage to codecov + run: | + bash <(curl -s https://codecov.io/bash) -f coverage/coverage.f.info || echo "Codecov did not collect coverage reports" diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml deleted file mode 100644 index 572b0e5548..0000000000 --- a/.github/workflows/daily.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Daily -on: - schedule: - - cron: "30 6 * * *" - workflow_dispatch: - -jobs: - call-multi-nim-common: - uses: ./.github/workflows/daily_common.yml - with: - nim-branch: "['version-1-6','version-2-0']" - cpu: "['amd64']" diff --git a/.github/workflows/daily_amd64.yml b/.github/workflows/daily_amd64.yml new file mode 100644 index 0000000000..a4031d7680 --- /dev/null +++ b/.github/workflows/daily_amd64.yml @@ -0,0 +1,14 @@ +name: Daily amd64 + +on: + schedule: + - cron: "30 6 * * *" + workflow_dispatch: + +jobs: + test_amd64: + name: Daily amd64 + uses: ./.github/workflows/base_daily_tests.yml + with: + nim: "[{'branch': 'version-1-6', 'memory_management': 'refc'}, {'branch': 'version-2-0', 'memory_management': 'refc'}]" + cpu: "['amd64']" diff --git a/.github/workflows/daily_common.yml b/.github/workflows/daily_common.yml index e6a56ae402..0b2e0d6197 100644 --- a/.github/workflows/daily_common.yml +++ b/.github/workflows/daily_common.yml @@ -1,12 +1,13 @@ -name: daily-common +name: Daily Common +# Serves as base workflow for daily tasks, it's not run by itself. on: workflow_call: inputs: - nim-branch: - description: 'Nim branch' + nim: + description: 'Nim Configuration' required: true - type: string + type: string # Following this format: [{"branch": ..., "memory_management": ...}, ...] cpu: description: 'CPU' required: true @@ -17,15 +18,20 @@ on: type: string default: "[]" +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: - delete-cache: + delete_cache: + name: Delete github action's branch cache runs-on: ubuntu-latest steps: - uses: snnaplab/delete-branch-cache-action@v1 - build: - needs: delete-cache - timeout-minutes: 120 + test: + needs: delete_cache + timeout-minutes: 90 strategy: fail-fast: false matrix: @@ -39,7 +45,7 @@ jobs: - os: windows builder: windows-2022 shell: msys2 {0} - branch: ${{ fromJSON(inputs.nim-branch) }} + nim: ${{ fromJSON(inputs.nim) }} cpu: ${{ fromJSON(inputs.cpu) }} exclude: ${{ fromJSON(inputs.exclude) }} @@ -47,9 +53,9 @@ jobs: run: shell: ${{ matrix.platform.shell }} - name: '${{ matrix.platform.os }}-${{ matrix.cpu }} (Nim ${{ matrix.branch }})' + name: '${{ matrix.platform.os }}-${{ matrix.cpu }} (Nim ${{ matrix.nim.branch }})' runs-on: ${{ matrix.platform.builder }} - continue-on-error: ${{ matrix.branch == 'devel' || matrix.branch == 'version-2-0' }} + continue-on-error: ${{ matrix.nim.branch == 'devel' || matrix.nim.branch == 'version-2-0' }} steps: - name: Checkout uses: actions/checkout@v4 @@ -59,11 +65,11 @@ jobs: with: os: ${{ matrix.platform.os }} shell: ${{ matrix.platform.shell }} - nim_branch: ${{ matrix.branch }} + nim_branch: ${{ matrix.nim.branch }} cpu: ${{ matrix.cpu }} - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '~1.15.5' cache: false @@ -71,14 +77,13 @@ jobs: - name: Install p2pd run: | V=1 bash scripts/build_p2pd.sh p2pdCache 124530a3 + + - name: Install dependencies + run: | + nimble install -y --depsOnly - name: Run tests run: | nim --version nimble --version - nimble install -y --depsOnly - NIMFLAGS="${NIMFLAGS} --mm:refc" nimble test - if [[ "${{ matrix.branch }}" == "devel" ]]; then - echo -e "\nTesting with '--mm:orc':\n" - NIMFLAGS="${NIMFLAGS} --mm:orc" nimble test - fi + NIMFLAGS="${NIMFLAGS} --mm:${{ matrix.nim.memory_management }}" nimble test diff --git a/.github/workflows/daily_devel.yml b/.github/workflows/daily_devel.yml new file mode 100644 index 0000000000..391494036f --- /dev/null +++ b/.github/workflows/daily_devel.yml @@ -0,0 +1,14 @@ +name: Daily Nim Devel + +on: + schedule: + - cron: "30 6 * * *" + workflow_dispatch: + +jobs: + test_nim_devel: + name: Daily Nim Devel + uses: ./.github/workflows/base_daily_tests.yml + with: + nim: "[{'branch': 'devel', 'memory_management': 'orc'}]" + cpu: "['amd64']" diff --git a/.github/workflows/daily_i386.yml b/.github/workflows/daily_i386.yml index 23aa075971..649c37b807 100644 --- a/.github/workflows/daily_i386.yml +++ b/.github/workflows/daily_i386.yml @@ -1,13 +1,15 @@ name: Daily i386 + on: schedule: - cron: "30 6 * * *" workflow_dispatch: jobs: - call-multi-nim-common: - uses: ./.github/workflows/daily_common.yml + test_i386: + name: Daily i386 (Linux) + uses: ./.github/workflows/base_daily_tests.yml with: - nim-branch: "['version-1-6','version-2-0', 'devel']" + nim: "[{'branch': 'version-1-6', 'memory_management': 'refc'}, {'branch': 'version-2-0', 'memory_management': 'refc'}, {'branch': 'devel', 'memory_management': 'orc'}]" cpu: "['i386']" exclude: "[{'platform': {'os':'macos'}}, {'platform': {'os':'windows'}}]" diff --git a/.github/workflows/daily_nim_devel.yml b/.github/workflows/daily_nim_devel.yml deleted file mode 100644 index d27ae5f1ea..0000000000 --- a/.github/workflows/daily_nim_devel.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Daily Nim Devel -on: - schedule: - - cron: "30 6 * * *" - workflow_dispatch: - -jobs: - call-multi-nim-common: - uses: ./.github/workflows/daily_common.yml - with: - nim-branch: "['devel']" - cpu: "['amd64']" diff --git a/.github/workflows/bumper.yml b/.github/workflows/dependencies.yml similarity index 51% rename from .github/workflows/bumper.yml rename to .github/workflows/dependencies.yml index 14d5026eba..00d97be9bf 100644 --- a/.github/workflows/bumper.yml +++ b/.github/workflows/dependencies.yml @@ -1,4 +1,5 @@ -name: Bumper +name: Dependencies + on: push: branches: @@ -6,34 +7,38 @@ on: workflow_dispatch: jobs: - bumpProjects: + bumper: + # Pushes new refs to interested external repositories, so they can do early testing against libp2p's newer versions runs-on: ubuntu-latest + name: Bump libp2p's version for ${{ matrix.target.repository }}:${{ matrix.target.ref }} strategy: fail-fast: false matrix: - target: [ - { repo: status-im/nimbus-eth2, branch: unstable }, - { repo: waku-org/nwaku, branch: master }, - { repo: codex-storage/nim-codex, branch: master } - ] + target: + - repository: status-im/nimbus-eth2 + ref: unstable + - repository: waku-org/nwaku + ref: master + - repository: codex-storage/nim-codex + ref: master steps: - - name: Clone repo - uses: actions/checkout@v2 + - name: Clone target repository + uses: actions/checkout@v4 with: - repository: ${{ matrix.target.repo }} - ref: ${{ matrix.target.branch }} + repository: ${{ matrix.target.repository }} + ref: ${{ matrix.target.ref}} path: nbc fetch-depth: 0 - token: ${{ secrets.ACTIONS_GITHUB_TOKEN }} + token: ${{ secrets.ACTIONS_GITHUB_TOKEN }} - - name: Checkout this ref + - name: Checkout this ref in target repository run: | cd nbc git submodule update --init vendor/nim-libp2p cd vendor/nim-libp2p git checkout $GITHUB_SHA - - name: Commit this bump + - name: Push this ref to target repository run: | cd nbc git config --global user.email "${{ github.actor }}@users.noreply.github.com" @@ -42,3 +47,4 @@ jobs: git branch -D nim-libp2p-auto-bump-${GITHUB_REF##*/} || true git switch -c nim-libp2p-auto-bump-${GITHUB_REF##*/} git push -f origin nim-libp2p-auto-bump-${GITHUB_REF##*/} + diff --git a/.github/workflows/doc.yml b/.github/workflows/documentation.yml similarity index 93% rename from .github/workflows/doc.yml rename to .github/workflows/documentation.yml index 42f6a88375..fd4525509b 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/documentation.yml @@ -1,4 +1,5 @@ -name: Docgen +name: Documentation Generation And Publishing + on: push: branches: @@ -14,7 +15,7 @@ jobs: continue-on-error: true steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: true @@ -34,7 +35,7 @@ jobs: ls ${GITHUB_REF##*/} - name: Clone the gh-pages branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: vacp2p/nim-libp2p ref: gh-pages @@ -65,7 +66,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - uses: actions/setup-python@v2 with: @@ -79,7 +80,7 @@ jobs: run: pip install mkdocs-material && nimble -y website - name: Clone the gh-pages branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: vacp2p/nim-libp2p ref: gh-pages diff --git a/.github/workflows/interop.yml b/.github/workflows/interop.yml index ecdb6c4388..57c5eb05f7 100644 --- a/.github/workflows/interop.yml +++ b/.github/workflows/interop.yml @@ -1,4 +1,5 @@ -name: Interoperability Testing +name: Interoperability Tests + on: pull_request: push: diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml new file mode 100644 index 0000000000..e572d11cdb --- /dev/null +++ b/.github/workflows/linters.yml @@ -0,0 +1,32 @@ +name: Linters + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + nph: + name: NPH + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base + + - name: Setup NPH + # Pin nph to a specific version to avoid sudden style differences. + # Updating nph version should be accompanied with running the new version on the fluffy directory. + run: | + VERSION="v0.5.1" + ARCHIVE="nph-linux_x64.tar.gz" + curl -L "https://github.com/arnetheduck/nph/releases/download/${VERSION}/${ARCHIVE}" -o ${ARCHIVE} + tar -xzf ${ARCHIVE} + + - name: Check style + run: | + shopt -s extglob # Enable extended globbing + ./nph --check examples libp2p tests tools *.@(nim|nims|nimble)