From 005d69d80f84891b6b6156ab76b77f4a0e3dd88b Mon Sep 17 00:00:00 2001 From: realaravinth Date: Mon, 6 Dec 2021 13:45:33 +0530 Subject: [PATCH] fix docker img publish routine --- .github/workflows/linux.yml | 34 ++++++++++++++--------------- Dockerfile | 3 ++- Makefile | 18 ++++++++-------- src/lib.rs | 43 +++++++++++++++++-------------------- 4 files changed, 48 insertions(+), 50 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index d8498a6..39a6be7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -37,30 +37,30 @@ jobs: profile: minimal override: false - - name: install virtualenv - run: pip install virtualenv + # - name: install virtualenv + # run: pip install virtualenv + # + # - name: install dependencies + # run: make env + # # - name: build docker image + # run: make docker-build + # + #- name: start docker container + # run: make docker-run - - name: install dependencies - run: make env + #- name: run tests + # run: make test - - name: build docker image - run: make docker-build - - - name: start docker container - run: make docker-run - - - name: run tests - run: make test - - - name: stop docker container - run: make docker-stop + #- name: stop docker container + # run: make docker-stop - name: Login to DockerHub - if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'realaravinth/pages' + if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/cache' uses: docker/login-action@v1 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: mcaptcha password: ${{ secrets.DOCKERHUB_TOKEN }} - name: build and publish docker images + if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/cache' run: make docker diff --git a/Dockerfile b/Dockerfile index c950467..3f6fee0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ ARG OSNICK=bullseye # ARCH=x64|arm64v8|arm32v7 ARG ARCH=x64 -FROM rust:1-bullseye as builder +FROM rust:1.57-bullseye as builder WORKDIR /src RUN set -ex; \ apt-get update; \ @@ -16,6 +16,7 @@ COPY Cargo.toml Cargo.lock /src/ RUN mkdir -p /src/src && touch /src/src/lib.rs RUN cargo build --release COPY . . +RUN cargo build --release #FROM redisfab/redis:${REDIS_VER}-${ARCH}-${OSNICK} diff --git a/Makefile b/Makefile index a767de6..b7a57fc 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,4 @@ -VERSION = "0.1.0:alpha-test" -DOCKER_IMG = "mcaptcha/cache$(VERSION)" -DOCKER_CONTAINER = "mcaptcha_cache_test" +DOCKER_CONTAINER = "test_instance" default: cargo build --release @@ -21,17 +19,18 @@ doc: cargo doc --no-deps --workspace --all-features --document-private-items docker: - docker build -t mcaptcha/cache:0.1.0-beta -t mcaptcha/cache:latest . - docker push mcaptcha/cache:0.1.0-beta - docker push mcaptcha/cache:latest + docker build -t mcaptcha/cache:broken-build . + #docker build -t mcaptcha/cache:0.1.0-beta -t mcaptcha/cache:latest . + #docker push mcaptcha/cache:0.1.0-beta + docker push mcaptcha/cache:broken-build docker-build: - docker build -t $(DOCKER_IMG) . + docker build -t mcaptcha/cache:0.1.0-beta -t mcaptcha/cache:latest . docker-run: - docker run --detach --name=$(DOCKER_CONTAINER) \ + docker run --name=$(DOCKER_CONTAINER) \ --publish 6379:6379 \ - $(DOCKER_IMG) + mcaptcha/cache:latest docker-stop: docker stop $(DOCKER_CONTAINER) || true @@ -43,6 +42,7 @@ env: @-pip install codespell test: + @ . venv/bin/activate && ./scripts/spellcheck.sh -c cargo test --all --all-features --no-fail-fast ./tests/test.py diff --git a/src/lib.rs b/src/lib.rs index 1ad05f6..6251d28 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +#![allow(clippy::not_unsafe_ptr_arg_deref)] + use lazy_static::lazy_static; use redis_module::NotifyEvent; use redis_module::{redis_command, redis_event_handler, redis_module}; @@ -78,27 +80,22 @@ pub fn on_delete(ctx: &Context, event_type: NotifyEvent, event: &str, key_name: } } -#[allow(clippy::not_unsafe_ptr_arg_deref)] -pub mod redis { - use super::*; - - redis_module! { - name: "mcaptcha_cahce", - version: PKG_VERSION, - data_types: [MCAPTCHA_BUCKET_TYPE, MCAPTCHA_MCAPTCHA_TYPE, MCAPTCHA_SAFETY_TYPE, MCAPTCHA_CHALLENGE_TYPE], - commands: [ - ["MCAPTCHA_CACHE.ADD_VISITOR", bucket::Bucket::counter_create, "write", 1, 1, 1], - ["MCAPTCHA_CACHE.GET", mcaptcha::MCaptcha::get_count, "readonly", 1, 1, 1], - ["MCAPTCHA_CACHE.ADD_CAPTCHA", mcaptcha::MCaptcha::add_captcha, "readonly", 1, 1, 1], - ["MCAPTCHA_CACHE.DELETE_CAPTCHA", mcaptcha::MCaptcha::delete_captcha, "write", 1, 1, 1], - ["MCAPTCHA_CACHE.RENAME_CAPTCHA", mcaptcha::MCaptcha::rename, "write", 1, 1, 1], - ["MCAPTCHA_CACHE.CAPTCHA_EXISTS", mcaptcha::MCaptcha::captcha_exists, "readonly", 1, 1, 1], - ["MCAPTCHA_CACHE.ADD_CHALLENGE", challenge::Challenge::create_challenge, "write", 1, 1, 1], - ["MCAPTCHA_CACHE.GET_CHALLENGE", challenge::Challenge::get_challenge, "write", 1, 1, 1], - ["MCAPTCHA_CACHE.DELETE_CHALLENGE", challenge::Challenge::delete_challenge, "write", 1, 1, 1], - ], - event_handlers: [ - [@EXPIRED @EVICTED: on_delete], - ] - } +redis_module! { + name: "mcaptcha_cahce", + version: PKG_VERSION, + data_types: [MCAPTCHA_BUCKET_TYPE, MCAPTCHA_MCAPTCHA_TYPE, MCAPTCHA_SAFETY_TYPE, MCAPTCHA_CHALLENGE_TYPE], + commands: [ + ["MCAPTCHA_CACHE.ADD_VISITOR", bucket::Bucket::counter_create, "write", 1, 1, 1], + ["MCAPTCHA_CACHE.GET", mcaptcha::MCaptcha::get_count, "readonly", 1, 1, 1], + ["MCAPTCHA_CACHE.ADD_CAPTCHA", mcaptcha::MCaptcha::add_captcha, "readonly", 1, 1, 1], + ["MCAPTCHA_CACHE.DELETE_CAPTCHA", mcaptcha::MCaptcha::delete_captcha, "write", 1, 1, 1], + ["MCAPTCHA_CACHE.RENAME_CAPTCHA", mcaptcha::MCaptcha::rename, "write", 1, 1, 1], + ["MCAPTCHA_CACHE.CAPTCHA_EXISTS", mcaptcha::MCaptcha::captcha_exists, "readonly", 1, 1, 1], + ["MCAPTCHA_CACHE.ADD_CHALLENGE", challenge::Challenge::create_challenge, "write", 1, 1, 1], + ["MCAPTCHA_CACHE.GET_CHALLENGE", challenge::Challenge::get_challenge, "write", 1, 1, 1], + ["MCAPTCHA_CACHE.DELETE_CHALLENGE", challenge::Challenge::delete_challenge, "write", 1, 1, 1], + ], + event_handlers: [ + [@EXPIRED @EVICTED: on_delete], + ] }