From 7d0fafd26e74a9183e09206cc2467d238ed867fe Mon Sep 17 00:00:00 2001 From: juanito87 Date: Fri, 2 Feb 2024 11:31:55 -0300 Subject: [PATCH 1/4] Updating ci worflow tyo have a release, testing some updates to the workflow --- .github/workflows/release.yml | 115 ++++++++++++++++++++++++++++++++++ ci/innernet-ref.txt | 1 + 2 files changed, 116 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 ci/innernet-ref.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..172e653 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,115 @@ +iname: Build and release template + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + workflow_dispatch: + push: + paths: + - 'ci/innernet-ref.txt' + - '.github/workflows/release.yml' + +jobs: + build: + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04] + + runs-on: [self-hosted,"${{ matrix.os }}"] + + steps: + - name: Notify workflow started + run: | + msg=$(jq -nc \ + --arg msg "${{ github.workflow }} run started on ${{ matrix.os }} for repo ${{ github.event.repository.name }}" \ + '{text:$msg}' ) + curl -s -X POST -H 'Content-type: application/json' --data "$msg" "${{ secrets.SLACKWEBHOOK }}" >/dev/null + + - uses: actions/checkout@v4 + with: + submodules: true + lfs: true + fetch-depth: 0 + + - name: get commit + run: | + innernetRef=$(grep -E '*' ./ci/innernet-ref.txt | tr -d '\n\r') + echo "innernetRef=$innernetRef" >> "$GITHUB_ENV" + echo "$innernetRef" + + - uses: actions/checkout@v4 + with: + repository: rpcpool/innernet + ref: "${{ env.innernetRef }}" + path: pathx + submodules: recursive + fetch-depth: 0 + lfs: true + + - name: get tag + run: | + curl -sL https://gist.github.com/Juanito87/e8b2d9f70302d863eecf02e52e747c26/raw/getTag.sh > ci/getTag.sh + source ci/getTag.sh sui + echo "CI_TAG=$CI_TAG" >> "$GITHUB_ENV" + echo "BUILD_NAME=$BUILD_NAME" >> "$GITHUB_ENV" + cd innernet + echo "channel=$(cat rust-toolchain.toml | grep channel | awk '{print $3}' | sed 's/"//g')" >> "$GITHUB_ENV" + + - name: set cargo env + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.channel }} + + - name: set build cargo cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + innernet/target/${{ matrix.os }} + key: ${{ runner.os }}_innernet_${{ hashFiles('innernet/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}_innernet + + - name: Build innernet + working-directory: innernet + env: + CARGO_TARGET_DIR: "${{ matrix.os }}" + run: | + build instructions + + - name: Rename builds + working-directory: innernet + run: | + mv ${{ matrix.os }}/release/innernet ${{matrix.os}}/release/innernet-${{ matrix.os }} + + - name: Publish artifact + uses: actions/upload-artifact@v3.1.1 + if: github.ref_name != 'main' + with: + name: innernetname + if-no-files-found: error + path: | + ${{matrix.os}}/release/innernet-${{ matrix.os }} + + - name: Publish to release + uses: softprops/action-gh-release@v1 + if: github.ref_name == 'main' + with: + name: ${{ env.BUILD_NAME }} + tag_name: ${{ env.BUILD_NAME }} + token: ${{ github.token }} + files: | + ${{matrix.os}}/release/innernet-${{ matrix.os }} + + - name: Notify workflow finished + if: always() + run: | + msg=$(jq -nc \ + --arg msg "${{ github.workflow }} run ${{ job.status }} on ${{ matrix.os }} for repo ${{ github.event.repository.name }}, running post run hooks" \ + '{text:$msg}' ) + curl -s -X POST -H 'Content-type: application/json' --data "$msg" "${{ secrets.SLACKWEBHOOK }}" >/dev/null diff --git a/ci/innernet-ref.txt b/ci/innernet-ref.txt new file mode 100644 index 0000000..ea0c811 --- /dev/null +++ b/ci/innernet-ref.txt @@ -0,0 +1 @@ +aa1ac515e827d31cc0a80298fc240ed7f9483368 From 13f4f535a6b04c4ea056920e4b88f698c115d66c Mon Sep 17 00:00:00 2001 From: juanito87 Date: Fri, 2 Feb 2024 11:45:17 -0300 Subject: [PATCH 2/4] Updating all workflows --- .github/workflows/docker-tests.yml | 7 ++-- .github/workflows/release.yml | 1 - .github/workflows/rust.yml | 56 ++++++++++++++++++------------ 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml index 5bb06ef..11b4977 100644 --- a/.github/workflows/docker-tests.yml +++ b/.github/workflows/docker-tests.yml @@ -1,8 +1,6 @@ name: Docker tests on: - push: - branches: [ main ] pull_request: branches: [ main ] @@ -10,12 +8,11 @@ jobs: build: - runs-on: ubuntu-latest + runs-on: [self-hosted,"${{ matrix.os }}"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Build the Docker images run: docker-tests/build-docker-images.sh - name: Run the Docker tests run: docker-tests/run-docker-tests.sh userspace - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 172e653..218790a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,7 +43,6 @@ jobs: with: repository: rpcpool/innernet ref: "${{ env.innernetRef }}" - path: pathx submodules: recursive fetch-depth: 0 lfs: true diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9a87103..0376852 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -12,35 +12,44 @@ on: jobs: test: - runs-on: ${{ matrix.os }} + runs-on: [self-hosted,"${{ matrix.os }}"] strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-20.04, ubuntu-22.04] steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + + - name: get channel + run: | + echo "channel=$(cat rust-toolchain.toml | grep channel | awk '{print $3}' | sed 's/"//g')" >> "$GITHUB_ENV" + + - name: set cargo env + uses: dtolnay/rust-toolchain@master with: - profile: minimal - toolchain: stable - override: true + toolchain: ${{ env.channel }} + - name: Install Dependencies (if Ubuntu) env: ACCEPT_EULA: Y run: sudo apt-get -y update && sudo apt-get install -f && sudo apt-get -y install libsqlite3-dev libclang-11-dev if: contains(runner.os, 'Linux') + - uses: Swatinem/rust-cache@v1 + - name: Build uses: actions-rs/cargo@v1 with: command: build args: --verbose + - name: Test uses: actions-rs/cargo@v1 with: command: test args: --verbose + - name: Test (IPv6) uses: actions-rs/cargo@v1 with: @@ -48,15 +57,19 @@ jobs: args: --features v6-test --verbose fmt: - runs-on: ubuntu-latest + runs-on: [self-hosted,"${{ matrix.os }}"] steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + + - name: get channel + run: | + echo "channel=$(cat rust-toolchain.toml | grep channel | awk '{print $3}' | sed 's/"//g')" >> "$GITHUB_ENV" + + - name: set cargo env + uses: dtolnay/rust-toolchain@master with: - profile: minimal - toolchain: nightly - override: true - components: rustfmt + toolchain: ${{ env.channel }} + - name: Rustfmt uses: actions-rs/cargo@v1 with: @@ -64,15 +77,14 @@ jobs: args: --all -- --check clippy: - runs-on: ubuntu-latest + runs-on: [self-hosted,"${{ matrix.os }}"] steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: clippy + - uses: actions/checkout@v4 + + - name: get channel + run: | + echo "channel=$(cat rust-toolchain.toml | grep channel | awk '{print $3}' | sed 's/"//g')" >> "$GITHUB_ENV" + - name: Clippy uses: actions-rs/cargo@v1 with: From ad5b904626ae73df63b48d789c3429f486d4f8b5 Mon Sep 17 00:00:00 2001 From: juanito87 Date: Fri, 2 Feb 2024 11:54:13 -0300 Subject: [PATCH 3/4] Updates. --- .github/workflows/release.yml | 4 +++- .github/workflows/rust.yml | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 218790a..6a547a8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -iname: Build and release template +name: Build and release template concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -9,6 +9,8 @@ on: push: paths: - 'ci/innernet-ref.txt' + pull_request: + paths: - '.github/workflows/release.yml' jobs: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0376852..25b98ca 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -4,11 +4,6 @@ on: push: branches: - '*' - tags-ignore: - - 'v*' - pull_request: - branches: - - '*' jobs: test: From 65183f2ac28684b8f81e90f9352acbff036bb1af Mon Sep 17 00:00:00 2001 From: juanito87 Date: Fri, 2 Feb 2024 12:00:17 -0300 Subject: [PATCH 4/4] Changing template name. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a547a8..a0622bb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Build and release template +name: Build and release innernet concurrency: group: ${{ github.workflow }}-${{ github.ref }}