Skip to content

Commit

Permalink
ci: upload build artifacts & prep for homebrew/winget support (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
MicaiahReid committed May 8, 2024
1 parent 11bde53 commit 8ef6827
Show file tree
Hide file tree
Showing 9 changed files with 353 additions and 86 deletions.
331 changes: 303 additions & 28 deletions .github/workflows/ci.yaml

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions .github/workflows/pkg-version-bump.yaml
@@ -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 Down Expand Up @@ -27,14 +27,18 @@ jobs:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GH_TOKEN }}
TAG: ${{ github.event.client_payload.tag || github.event.inputs.tag }}
run: |
# Get version info
VERSION=$(echo "${ENV#v}")
# Configure git configs
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}" \
--version "${VERSION}" \
${{ github.event.repository.name }}
winget:
Expand All @@ -45,8 +49,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 +61,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
6 changes: 3 additions & 3 deletions components/chainhook-cli/src/service/tests/mod.rs
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
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
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>
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
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.73.0"
channel = "1.76.0"

0 comments on commit 8ef6827

Please sign in to comment.