diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db08c9e..d901acc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,18 +1,12 @@ on: - push: - branches: - - main - paths: - - 'Cargo.toml' - - 'Cargo.lock' - - 'Dockerfile' - - 'src/**' pull_request: paths: - 'Cargo.toml' - 'Cargo.lock' - 'Dockerfile' + - 'deployment.yml' - 'src/**' + - '.github/**' name: Continuous integration @@ -93,33 +87,36 @@ jobs: command: clippy args: -- -D warnings - build: - name: Build and push to registry + test_coverage: + name: Test & Coverage runs-on: ubuntu-latest needs: [fmt, clippy] - if: github.ref == 'refs/heads/main' steps: - name: Checkout repository uses: actions/checkout@v2 - - name: Setup ssh key - uses: webfactory/ssh-agent@v0.5.0 + - name: Cache + uses: actions/cache@v2 + id: cache + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Setup git credentials + uses: fusion-engineering/setup-git-credentials@v2 with: - ssh-private-key: ${{secrets.GH_ACTIONS_SSH_PRIVATE_KEY}} - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 + credentials: ${{secrets.GIT_USER_CREDENTIALS}} + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Install tarpaulin + run: cargo install cargo-tarpaulin + - name: Generate coverage + run: cargo tarpaulin --out Xml + - name: Upload to codecov + uses: codecov/codecov-action@v1 with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-1 - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - - name: Build, tag, and push image to Amazon ECR - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: volatility-harvesting - DOCKER_BUILDKIT: 1 - IMAGE_TAG: ${{ github.sha }} - run: | - docker build --ssh default -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + token: ${{secrets.CODECOV_TOKEN}} + fail_ci_if_error: true diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..bd03d73 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,70 @@ +name: Deploy +on: + release: + types: [published] + +jobs: + cancel-previous: + name: Cancel Previous Runs + runs-on: ubuntu-latest + steps: + - name: Cancel actions + uses: styfle/cancel-workflow-action@0.8.0 + with: + access_token: ${{ github.token }} + + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Cache + uses: actions/cache@v2 + id: cache + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Setup git credentials + uses: fusion-engineering/setup-git-credentials@v2 + with: + credentials: ${{secrets.GIT_USER_CREDENTIALS}} + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Run tests + run: cargo test + + build: + name: Build and push to registry + runs-on: ubuntu-latest + needs: test + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Setup ssh key + uses: webfactory/ssh-agent@v0.5.0 + with: + ssh-private-key: ${{secrets.GH_ACTIONS_SSH_PRIVATE_KEY}} + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + - name: Build, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: volatility-harvesting + DOCKER_BUILDKIT: 1 + IMAGE_TAG: ${{ github.event.release.name }} + run: | + docker build --ssh default -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG diff --git a/Cargo.lock b/Cargo.lock index bb11292..022dfe7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -880,9 +880,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +checksum = "8270314b5ccceb518e7e578952f0b72b88222d02e8f77f5ecf7abbb673539041" dependencies = [ "bitflags", ] @@ -1309,7 +1309,7 @@ checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "volatility-harvesting" -version = "0.3.1" +version = "1.0.0" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 3ae3e3d..59cd19a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "volatility-harvesting" -version = "0.3.1" +version = "1.0.0" authors = ["RollenRegistratorBot "] edition = "2018"