Skip to content

Commit

Permalink
ci: revamp ci (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
MicaiahReid authored May 15, 2024
1 parent 9011a0c commit ddb1e41
Show file tree
Hide file tree
Showing 13 changed files with 358 additions and 106 deletions.
331 changes: 303 additions & 28 deletions .github/workflows/ci.yaml

Large diffs are not rendered by default.

28 changes: 5 additions & 23 deletions .github/workflows/pkg-version-bump.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##
## Bumps the Clarinet version listed on various package managers.
## Bumps the Chainhook version listed on various package managers.
##

name: Package Version Bump
Expand All @@ -18,24 +18,6 @@ env:
GIT_USER_EMAIL: 45208873+blockstack-devops@users.noreply.github.com

jobs:
homebrew:
name: Homebrew
runs-on: macos-latest
steps:
- name: Homebrew version bump
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GH_TOKEN }}
TAG: ${{ github.event.client_payload.tag || github.event.inputs.tag }}
run: |
git config --global user.name "${GIT_USER_NAME}"
git config --global user.email "${GIT_USER_EMAIL}"
brew update
brew bump-formula-pr \
--no-browse \
--no-audit \
--tag "${TAG}" \
${{ github.event.repository.name }}

winget:
name: Winget
Expand All @@ -45,8 +27,8 @@ jobs:
env:
TAG: ${{ github.event.client_payload.tag || github.event.inputs.tag }}
run: |
# Get version infoq
$VERSION=${env:TAG}.substring(1)
# Get version info
VERSION=$(echo "${TAG#v}")
# Configure git configs
git config --global user.name "${env:GIT_USER_NAME}"
Expand All @@ -57,8 +39,8 @@ jobs:
# Update manifest and submit PR
./wingetcreate.exe update `
--urls https://github.com/${{ github.repository }}/releases/download/${env:TAG}/clarinet-windows-x64.msi `
--urls https://github.com/${{ github.repository }}/releases/download/${env:TAG}/chainhook-windows-x64.msi `
--version ${VERSION} `
--token ${{ secrets.GH_TOKEN }} `
--submit `
HiroSystems.Clarinet
HiroSystems.Chainhook
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [1.6.1](https://github.com/hirosystems/chainhook/compare/v1.6.0...v1.6.1) (2024-05-15)

### Bug Fixes

* serialize brc-20 data ([#585](https://github.com/hirosystems/chainhook/issues/585)) ([9011a0c](https://github.com/hirosystems/chainhook/commit/9011a0ce49d9d38a6d7a6776d7f37b709a355386))


## [1.6.0](https://github.com/hirosystems/chainhook/compare/v1.5.1...v1.6.0) (2024-05-09)


Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/chainhook-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chainhook"
version = "1.6.0"
version = "1.6.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
6 changes: 3 additions & 3 deletions components/chainhook-cli/src/service/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ async fn it_seeds_block_pool_on_startup() -> Result<(), String> {
Ok(())
}

fn cleanup_err(
pub fn cleanup_err(
error: String,
working_dir: &str,
redis_port: u16,
Expand All @@ -1007,8 +1007,8 @@ fn cleanup_err(
format!("test failed with error: {error}")
}

fn cleanup(working_dir: &str, redis_port: u16, redis_process: &mut Child) {
std::fs::remove_dir_all(&working_dir).unwrap();
pub fn cleanup(working_dir: &str, redis_port: u16, redis_process: &mut Child) {
let _ = std::fs::remove_dir_all(&working_dir);
flush_redis(redis_port);
redis_process.kill().unwrap();
}
58 changes: 23 additions & 35 deletions components/chainhook-cli/src/service/tests/observer_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use serde_json::Value;
use test_case::test_case;

use crate::service::tests::{
cleanup, cleanup_err,
helpers::{
build_predicates::build_stacks_payload,
mock_service::{
Expand All @@ -26,7 +27,7 @@ use super::helpers::{

#[tokio::test]
#[cfg_attr(not(feature = "redis_tests"), ignore)]
async fn ping_endpoint_returns_metrics() {
async fn ping_endpoint_returns_metrics() -> Result<(), String> {
let TestSetupResult {
mut redis_process,
working_dir,
Expand All @@ -43,34 +44,27 @@ async fn ping_endpoint_returns_metrics() {
let predicate = build_stacks_payload(Some("devnet"), None, None, None, Some(uuid));
let _ = call_register_predicate(&predicate, chainhook_service_port)
.await
.unwrap_or_else(|e| {
std::fs::remove_dir_all(&working_dir).unwrap();
flush_redis(redis_port);
redis_process.kill().unwrap();
panic!("test failed with error: {e}");
});

let metrics = call_ping(stacks_ingestion_port).await.unwrap_or_else(|e| {
std::fs::remove_dir_all(&working_dir).unwrap();
flush_redis(redis_port);
redis_process.kill().unwrap();
panic!("test failed with error: {e}");
});
.map_err(|e| cleanup_err(e, &working_dir, redis_port, &mut redis_process))?;

sleep(Duration::new(1, 0));
let metrics = call_ping(stacks_ingestion_port)
.await
.map_err(|e| cleanup_err(e, &working_dir, redis_port, &mut redis_process))?;
let result = metrics
.get("stacks")
.unwrap()
.get("registered_predicates")
.unwrap();
assert_eq!(result, 1);

std::fs::remove_dir_all(&working_dir).unwrap();
flush_redis(redis_port);
redis_process.kill().unwrap();
sleep(Duration::new(1, 0));
cleanup(&working_dir, redis_port, &mut redis_process);
Ok(())
}

#[tokio::test]
#[cfg_attr(not(feature = "redis_tests"), ignore)]
async fn prometheus_endpoint_returns_encoded_metrics() {
async fn prometheus_endpoint_returns_encoded_metrics() -> Result<(), String> {
let TestSetupResult {
mut redis_process,
working_dir,
Expand All @@ -85,27 +79,21 @@ async fn prometheus_endpoint_returns_encoded_metrics() {

let uuid = &get_random_uuid();
let predicate = build_stacks_payload(Some("devnet"), None, None, None, Some(uuid));
let _ = call_register_predicate(&predicate, chainhook_service_port)
call_register_predicate(&predicate, chainhook_service_port)
.await
.unwrap_or_else(|e| {
std::fs::remove_dir_all(&working_dir).unwrap();
flush_redis(redis_port);
redis_process.kill().unwrap();
panic!("test failed with error: {e}");
});

let metrics = call_prometheus(prometheus_port).await.unwrap_or_else(|e| {
std::fs::remove_dir_all(&working_dir).unwrap();
flush_redis(redis_port);
redis_process.kill().unwrap();
panic!("test failed with error: {e}");
});
.map_err(|e| cleanup_err(e, &working_dir, redis_port, &mut redis_process))?;

sleep(Duration::new(1, 0));
let metrics = call_prometheus(prometheus_port)
.await
.map_err(|e| cleanup_err(e, &working_dir, redis_port, &mut redis_process))?;

const EXPECTED: &'static str = "# HELP chainhook_stx_registered_predicates The number of Stacks predicates that have been registered by the Chainhook node.\n# TYPE chainhook_stx_registered_predicates gauge\nchainhook_stx_registered_predicates 1\n";
assert!(metrics.contains(EXPECTED));

std::fs::remove_dir_all(&working_dir).unwrap();
flush_redis(redis_port);
redis_process.kill().unwrap();
sleep(Duration::new(1, 0));
cleanup(&working_dir, redis_port, &mut redis_process);
Ok(())
}

async fn await_observer_started(port: u16) {
Expand Down
File renamed without changes.
26 changes: 13 additions & 13 deletions wix/main.wxs → components/chainhook-cli/wix/main.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<Product
Id='*'
Name='clarinet'
Name='chainhook'
UpgradeCode='E41901A3-0B71-4D86-9175-B12D7C7533BE'
Manufacturer='Hiro Systems'
Language='1033'
Expand All @@ -42,7 +42,7 @@

<Package Id='*'
Keywords='Installer'
Description='Clarinet is a clarity runtime packaged as a command line tool, designed to facilitate smart contract understanding, development, testing and deployment.'
Description='Chainhook is a reorg-aware indexing engine for the Stacks and Bitcoin blockchains.'
Manufacturer='Hiro Systems'
InstallerVersion='450'
Languages='1033'
Expand All @@ -56,11 +56,11 @@
DowngradeErrorMessage='A newer version of [ProductName] is already installed. Setup will now exit.'/>

<Media Id='1' Cabinet='media1.cab' EmbedCab='yes' DiskPrompt='CD-ROM #1'/>
<Property Id='DiskPrompt' Value='clarinet Installation'/>
<Property Id='DiskPrompt' Value='chainhook Installation'/>

<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='$(var.PlatformProgramFilesFolder)' Name='PFiles'>
<Directory Id='APPLICATIONFOLDER' Name='clarinet'>
<Directory Id='APPLICATIONFOLDER' Name='chainhook'>
<!--
Disabling the license sidecar file in the installer is a two step process:
Expand All @@ -72,7 +72,7 @@
<File Id='LicenseFile'
Name='License.rtf'
DiskId='1'
Source='wix/License.rtf'
Source='components/chainhook-cli/wix/License.rtf'
KeyPath='yes'/>
</Component>

Expand All @@ -90,9 +90,9 @@
<Component Id='binary0' Guid='*' Win64='$(var.Win64)'>
<File
Id='exe0'
Name='clarinet.exe'
Name='chainhook.exe'
DiskId='1'
Source='target/x86_64-pc-windows-msvc/$(var.Profile)/clarinet.exe'
Source='target/x86_64-pc-windows-msvc/$(var.Profile)/chainhook.exe'
KeyPath='yes'/>
</Component>
</Directory>
Expand Down Expand Up @@ -134,10 +134,10 @@
Add/Remove Programs control panel requires commenting out or
removing the following `Icon` and `Property` tags.
-->
<Icon Id='ProductICO' SourceFile='docs/images/clarinet.ico'/>
<Property Id='ARPPRODUCTICON' Value='ProductICO' />
<!-- <Icon Id='ProductICO' SourceFile='docs/images/chainhook.ico'/> -->
<!-- <Property Id='ARPPRODUCTICON' Value='ProductICO' /> -->

<Property Id='ARPHELPLINK' Value='https://github.com/hirosystems/clarinet'/>
<Property Id='ARPHELPLINK' Value='https://github.com/hirosystems/chainhook/tree/build/upload-builds'/>

<UI>
<UIRef Id='WixUI_FeatureTree'/>
Expand All @@ -157,7 +157,7 @@
Disabling the EULA dialog in the installer requires commenting out
or removing the following `WixVariable` tag
-->
<WixVariable Id='WixUILicenseRtf' Value='wix/License.rtf'/>
<WixVariable Id='WixUILicenseRtf' Value='components/chainhook-cli/wix/License.rtf'/>


<!--
Expand All @@ -168,15 +168,15 @@
The banner BMP dimensions are 493 x 58 pixels.
-->
<WixVariable Id='WixUIBannerBmp' Value='docs/images/clarinet-banner.bmp'/>
<WixVariable Id='WixUIBannerBmp' Value='docs/images/chainhook-banner.bmp'/>

<!--
Disabling the dialog image in the installer requires commenting out or
removing the following `WixVariable` tag.
The dialog BMP dimensions are 493 x 312 pixels.
-->
<WixVariable Id='WixUIDialogBmp' Value='docs/images/clarinet-dialog.bmp'/>
<WixVariable Id='WixUIDialogBmp' Value='docs/images/chainhook-dialog.bmp'/>
</Product>

</Wix>
2 changes: 1 addition & 1 deletion docs/chainhook-openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.0",
"info": {
"title": "chainhook",
"version": "1.6.0"
"version": "1.6.1"
},
"paths": {
"/ping": {
Expand Down
Binary file added docs/images/chainhook-banner.bmp
Binary file not shown.
Binary file added docs/images/chainhook-dialog.bmp
Binary file not shown.
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.73.0"
channel = "1.77.0"

0 comments on commit ddb1e41

Please sign in to comment.