Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

feat: Periodic syndication checks to IPFS Kubo #685

Merged
merged 5 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .github/workflows/report_test_flakes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
on:
workflow_call:

name: 'Workflow Analysis'

jobs:
report-test-flakes:
name: 'Report test flakes'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/download-artifact@v3
- name: Parse test results
id: parse-test-results
run: |
sudo apt-get install colorized-logs

echo -n 'results=[' >> $GITHUB_OUTPUT

ENTRIES=""

for RESULTS_DIR in test-results-*/ ; do
mapfile -t target <$RESULTS_DIR/target

PLATFORM="${target[0]}"
FEATURES="${target[1]}"
TOOLCHAIN="${target[2]}"

LOG_PATH="$RESULTS_DIR/log"
csplit -q "$LOG_PATH" %^------------%

SUMMARY=""

if [[ -f "./xx00" ]]; then
SUMMARY=$(tail ./xx00 -n+2 | ansi2txt | jq -M --compact-output --raw-input --slurp . | sed -e 's/\\/\\\\/g')
else
continue
fi

ENTRY="{\"platform\":\"$PLATFORM\",\"features\":\"$FEATURES\",\"toolchain\":\"$TOOLCHAIN\",\"summary\":$SUMMARY}"

if [ -z "$ENTRIES" ]; then
ENTRIES="$ENTRY"
else
ENTRIES="$ENTRIES,$ENTRY"
fi

done

echo -n "$ENTRIES ]" >> $GITHUB_OUTPUT
- name: Report test flakes
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const results = JSON.parse(`${{ steps.parse-test-results.outputs.results }}`);

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const testFlakeAnalysisHeader = 'Test flake analysis';
const existingComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes(testFlakeAnalysisHeader)
});

let body = '';

if (results.length == 0) {
body = "No test results to analyze. Maybe none of the test runs passed?";
} else {

let table = "\n\n| status | platform | features | toolchain |\n|:---:|---|---|---|\n";

const flakeSummaries = [];

for (result of results) {
const isFlakey = result.summary.indexOf("FLAKY") > 0;

table += `| ${ isFlakey ? "🟡" : "🟢" } | \`${ result.platform }\` | \`${ result.features }\` | \`${result.toolchain}\` |\n`;

if (isFlakey) {
flakeSummaries.push(`#### Flake summary for \`${ result.platform }\`, \`${ result.features }\`, \`${ result.toolchain }\`

\`\`\`shell
${ result.summary }
\`\`\``);
}
}

if (flakeSummaries.length == 0) {
body += '\nNo flakes detected 🎉\n\n'
}

body += table;

if (flakeSummaries.length > 0) {
body += "\n\n";
body += flakeSummaries.join('\n\n');
}
}

body = `### ${testFlakeAnalysisHeader}

${body}`;

if (existingComment) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body
});
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
});
}
94 changes: 50 additions & 44 deletions .github/workflows/run_test_suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,6 @@ jobs:
swift build --sanitize=address
swift test --sanitize=address

run-test-suite-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: 'Setup Rust'
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
- name: 'Install environment packages'
run: |
choco install -y cmake protoc openssl
shell: sh
- name: 'Install IPFS Kubo'
uses: ibnesayeed/setup-ipfs@master
with:
ipfs_version: v0.17.0
run_daemon: true
- name: 'Run Rust native target tests'
run: cargo test --features test-kubo,helpers
env:
NOOSPHERE_LOG: deafening

run-linting-linux:
runs-on: ubuntu-latest
steps:
Expand All @@ -78,15 +56,31 @@ jobs:
- name: 'Run Linter'
run: cargo clippy --all -- -D warnings

run-test-suite-linux:
runs-on: ubuntu-latest
run-rust-test-suite:
name: 'Run Rust test suite'
strategy:
matrix:
features: ['test-kubo,headers', 'test-kubo,headers,rocksdb']
platform: ['ubuntu-latest', 'windows-latest', 'macos-13']
cdata marked this conversation as resolved.
Show resolved Hide resolved
toolchain: ['stable']
exclude:
- platform: 'windows-latest'
features: 'test-kubo,headers,rocksdb'
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: 'Setup Rust'
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
- name: 'Install environment packages'
rustup toolchain install ${{matrix.toolchain}}
- name: 'Install environment packages (Windows)'
if: ${{ matrix.platform == 'windows-latest' }}
run: |
choco install -y cmake protoc openssl
shell: sh
- name: 'Install environment packages (Linux)'
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
sudo apt-get update -qqy
sudo apt-get install jq protobuf-compiler cmake
Expand All @@ -95,28 +89,40 @@ jobs:
with:
ipfs_version: v0.17.0
run_daemon: true
- name: 'Run Rust native target tests'
run: NOOSPHERE_LOG=deafening cargo test --features test-kubo,headers

run-test-suite-linux-rocksdb:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: 'Setup Rust'
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@v1.4.4
- name: Install binaries from cargo
run: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
- name: 'Install environment packages'
cargo +${{ matrix.toolchain }} binstall cargo-nextest --no-confirm --force
- name: 'Run Rust tests'
shell: bash
run: |
sudo apt-get update -qqy
sudo apt-get install jq protobuf-compiler cmake libclang-dev
- name: 'Install IPFS Kubo'
uses: ibnesayeed/setup-ipfs@master
mkdir -p test-results

echo "${{ matrix.platform }}
${{ matrix.features }}
${{ matrix.toolchain}}" > test-results/target

FEATURES="";

if [ -n "${{matrix.features}}" ]; then
FEATURES="--features ${{matrix.features}}"
fi

cargo +${{ matrix.toolchain }} nextest run $FEATURES --retries 5 --color always 2>&1 | tee test-results/log
env:
NOOSPHERE_LOG: academic
- uses: actions/upload-artifact@v3
with:
ipfs_version: v0.17.0
run_daemon: true
- name: 'Run Rust native target tests (RocksDB)'
run: NOOSPHERE_LOG=defeaning cargo test -p noosphere -p noosphere-storage --features rocksdb,test-kubo
name: test-results-${{ hashFiles('./test-results') }}
path: ./test-results

report-test-flakes:
name: 'Report test flakes (Linux)'
needs: ['run-rust-test-suite']
if: always()
uses: ./.github/workflows/report_test_flakes.yaml
secrets: inherit

run-test-suite-linux-c:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion images/orb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ FROM ubuntu:latest
RUN mkdir -p /root/.noosphere
RUN mkdir -p /root/sphere

ENV RUST_LOG="info,tower_http,noosphere,noosphere_cli,noosphere_ipfs,noosphere_storage,noosphere_core,noosphere_storage,noosphere_api,orb=debug"
ENV NOOSPHERE_LOG="deafening"
VOLUME ["/root/.noosphere", "/root/sphere"]
EXPOSE 4433

Expand Down
5 changes: 4 additions & 1 deletion rust/noosphere-core/src/api/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ where
.stream()
.map(|block| match block {
Ok(block) => Ok(block),
Err(error) => Err(anyhow!(error)),
Err(error) => {
warn!("Replication stream ended prematurely");
Err(anyhow!(error))
}
}),
)
}
Expand Down
6 changes: 3 additions & 3 deletions rust/noosphere-core/src/stream/memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ where
};

if replicate_authority {
debug!("Replicating authority...");
trace!("Replicating authority...");
let authority = sphere.get_authority().await?;
let store = store.clone();

Expand All @@ -105,7 +105,7 @@ where
}

if replicate_address_book {
debug!("Replicating address book...");
trace!("Replicating address book...");
let address_book = sphere.get_address_book().await?;
let identities = address_book.get_identities().await?;

Expand All @@ -121,7 +121,7 @@ where
}

if replicate_content {
debug!("Replicating content...");
trace!("Replicating content...");
let content = sphere.get_content().await?;

tasks.spawn(walk_versioned_map_changes_and(content, store.clone(), move |_, link, store| async move {
Expand Down
2 changes: 1 addition & 1 deletion rust/noosphere-core/src/view/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<'a, 'b, S: BlockStore> BodyChunkDecoder<'a, 'b, S> {
let store = self.1.clone();
Box::pin(try_stream! {
while let Some(cid) = next {
debug!("Unpacking block {}...", cid);
trace!("Unpacking block {}...", cid);
let chunk = store.load::<DagCborCodec, BodyChunkIpld>(&cid).await.map_err(|error| {
std::io::Error::new(std::io::ErrorKind::UnexpectedEof, error.to_string())
})?;
Expand Down
3 changes: 2 additions & 1 deletion rust/noosphere-gateway/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ where

let ipfs_client = KuboClient::new(&ipfs_api)?;

let (syndication_tx, syndication_task) = start_ipfs_syndication::<C, S>(ipfs_api.clone());
let (syndication_tx, syndication_task) =
start_ipfs_syndication::<C, S>(ipfs_api.clone(), vec![sphere_context.clone()]);
let (name_system_tx, name_system_task) = start_name_system::<C, S>(
NameSystemConfiguration {
connection_type: NameSystemConnectionType::Remote(name_resolver_api),
Expand Down
Loading