Skip to content

Commit

Permalink
feat(ci): docker local caching (#27)
Browse files Browse the repository at this point in the history
* fix(ci): remove markdown lint

* feat: local docker cache

* fix: clippy

* fix: prettier
  • Loading branch information
EvolveArt authored Jun 13, 2024
1 parent 3fd040c commit 2f30af8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push by digest
id: build
uses: docker/build-push-action@v4
Expand All @@ -60,8 +68,17 @@ jobs:
file: Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE
}},push-by-digest=true,name-canonical=true,push=true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true

- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Export digest
run: |
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ jobs:
run: |-
npx prettier --check .
markdown-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: avto-dev/markdown-lint@v1
with:
config: "./.markdownlint.json"
args: "."
ignore: "./target"

toml-lint:
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 5 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ pub struct Config {
/// We are using `ArcSwap` as it allow us to replace the new `Config` with
/// a new one which is required when running test cases. This approach was
/// inspired from here - https://github.com/matklad/once_cell/issues/127
#[allow(unused)]
pub static CONFIG: OnceCell<ArcSwap<Config>> = OnceCell::const_new();

#[allow(unused)]
impl Config {
pub async fn new(config_input: ConfigInput) -> Self {
let indexer_url =
Expand Down Expand Up @@ -166,6 +168,7 @@ pub struct ConfigInput {
pub future_pairs: Vec<String>,
}

#[allow(unused)]
pub async fn get_config(config_input: Option<ConfigInput>) -> Guard<Arc<Config>> {
let cfg = CONFIG
.get_or_init(|| async {
Expand All @@ -181,6 +184,7 @@ pub async fn get_config(config_input: Option<ConfigInput>) -> Guard<Arc<Config>>
/// This function is used to periodically update the configuration settings
/// from the environment variables. This is useful when we want to update the
/// configuration settings without restarting the service.
#[allow(unused)]
pub async fn periodic_config_update() {
let interval = Duration::from_secs(CONFIG_UPDATE_INTERVAL); // Set the update interval as needed (3 hours in this example)

Expand All @@ -205,6 +209,7 @@ pub async fn periodic_config_update() {
/// However, when running tests, we often want to reinitialize because we want to clear the DB and
/// set it up again for reuse in new tests. By calling `config_force_init` we replace the already
/// stored config inside `ArcSwap` with the new configuration and pool settings.
#[allow(unused)]
#[cfg(test)]
pub async fn config_force_init(config_input: ConfigInput) {
match CONFIG.get() {
Expand Down
3 changes: 3 additions & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use lazy_static::lazy_static;
use phf::phf_map;
use prometheus::{opts, register_gauge_vec, register_int_gauge_vec, GaugeVec, IntGaugeVec};

#[allow(unused)]
pub(crate) static COINGECKO_IDS: phf::Map<&'static str, &'static str> = phf_map! {
"BTC/USD" => "bitcoin",
"ETH/USD" => "ethereum",
Expand Down Expand Up @@ -117,7 +118,9 @@ lazy_static! {
.unwrap();
}

#[allow(unused)]
pub const FEE_TOKEN_DECIMALS: i32 = 18;
#[allow(unused)]
pub const FEE_TOKEN_ADDRESS: &str =
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7";

Expand Down

0 comments on commit 2f30af8

Please sign in to comment.