From 75db8948af6c35ac7e76a1fad35746d801222eb2 Mon Sep 17 00:00:00 2001 From: Sebastian Rollen Date: Wed, 14 Apr 2021 15:59:11 -0400 Subject: [PATCH 1/2] change tag format to semver --- .github/workflows/ci.yml | 43 +-------------- .github/workflows/deploy.yml | 70 ++++++++++++++++++++++++ Cargo.lock | 102 +++++++++++++++++------------------ Cargo.toml | 2 +- 4 files changed, 124 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd42385..d901acc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,13 +1,4 @@ on: - push: - branches: - - main - paths: - - 'Cargo.toml' - - 'Cargo.lock' - - 'Dockerfile' - - 'deployment.yml' - - 'src/**' pull_request: paths: - 'Cargo.toml' @@ -15,6 +6,7 @@ on: - 'Dockerfile' - 'deployment.yml' - 'src/**' + - '.github/**' name: Continuous integration @@ -95,7 +87,7 @@ jobs: command: clippy args: -- -D warnings - coverage: + test_coverage: name: Test & Coverage runs-on: ubuntu-latest needs: [fmt, clippy] @@ -128,34 +120,3 @@ jobs: with: token: ${{secrets.CODECOV_TOKEN}} fail_ci_if_error: true - - build: - name: Build and push to registry - runs-on: ubuntu-latest - needs: [coverage, 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 - 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: alpaca-data-relay - 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 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f19f32f --- /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: alpaca-data-relay + 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 845e066..4b40b3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,18 +34,18 @@ dependencies = [ "chrono", "futures", "log", - "reqwest 0.11.2", + "reqwest 0.11.3", "serde 1.0.125", "serde_json", "thiserror", - "tokio 1.4.0", + "tokio 1.5.0", "tokio-tungstenite", "uuid", ] [[package]] name = "alpaca-data-relay" -version = "0.3.0" +version = "1.0.0" dependencies = [ "alpaca", "anyhow", @@ -57,7 +57,7 @@ dependencies = [ "sentry", "serde 1.0.125", "serde_json", - "tokio 1.4.0", + "tokio 1.5.0", "tracing", "tracing-log", "tracing-subscriber", @@ -344,9 +344,9 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "futures" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1" +checksum = "a9d5813545e459ad3ca1bff9915e9ad7f1a47dc6a91b627ce321d5863b7dd253" dependencies = [ "futures-channel", "futures-core", @@ -359,9 +359,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" +checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25" dependencies = [ "futures-core", "futures-sink", @@ -369,15 +369,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94" +checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815" [[package]] name = "futures-executor" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891a4b7b96d84d5940084b2a37632dd65deeae662c114ceaa2c879629c9c0ad1" +checksum = "10f6cb7042eda00f0049b1d2080aa4b93442997ee507eb3828e8bd7577f94c9d" dependencies = [ "futures-core", "futures-task", @@ -386,15 +386,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59" +checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04" [[package]] name = "futures-macro" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea405816a5139fb39af82c2beb921d52143f556038378d6db21183a5c37fbfb7" +checksum = "668c6733a182cd7deb4f1de7ba3bf2120823835b3bcfbeacf7d2c4a773c1bb8b" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -404,21 +404,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3" +checksum = "5c5629433c555de3d82861a7a4e3794a4c40040390907cfbfd7143a92a426c23" [[package]] name = "futures-task" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80" +checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc" [[package]] name = "futures-util" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" +checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025" dependencies = [ "futures-channel", "futures-core", @@ -506,8 +506,8 @@ dependencies = [ "http", "indexmap", "slab", - "tokio 1.4.0", - "tokio-util 0.6.5", + "tokio 1.5.0", + "tokio-util 0.6.6", "tracing", ] @@ -539,9 +539,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" +checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" dependencies = [ "bytes 1.0.1", "fnv", @@ -571,9 +571,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.3.5" +version = "1.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "615caabe2c3160b313d52ccc905335f4ed5f10881dd63dc5699d47e90be85691" +checksum = "bc35c995b9d93ec174cf9a27d425c7892722101e14993cd227fdb51d70cf9589" [[package]] name = "httpdate" @@ -623,7 +623,7 @@ dependencies = [ "itoa", "pin-project", "socket2 0.4.0", - "tokio 1.4.0", + "tokio 1.5.0", "tower-service", "tracing", "want", @@ -651,7 +651,7 @@ dependencies = [ "bytes 1.0.1", "hyper 0.14.5", "native-tls", - "tokio 1.4.0", + "tokio 1.5.0", "tokio-native-tls", ] @@ -769,9 +769,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714" +checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41" [[package]] name = "libz-sys" @@ -1275,7 +1275,7 @@ dependencies = [ "serde_derive", "serde_json", "slab", - "tokio 1.4.0", + "tokio 1.5.0", ] [[package]] @@ -1293,9 +1293,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", ] @@ -1374,9 +1374,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf12057f289428dbf5c591c74bf10392e4a8003f993405a902f20117019022d4" +checksum = "2296f2fac53979e8ccbc4a1136b25dcefd37be9ed7e4a1f6b05a6029c84ff124" dependencies = [ "base64", "bytes 1.0.1", @@ -1398,7 +1398,7 @@ dependencies = [ "serde 1.0.125", "serde_json", "serde_urlencoded", - "tokio 1.4.0", + "tokio 1.5.0", "tokio-native-tls", "url", "wasm-bindgen", @@ -1706,9 +1706,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87" +checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb" dependencies = [ "proc-macro2", "quote", @@ -1782,9 +1782,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" +checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" dependencies = [ "tinyvec_macros", ] @@ -1815,9 +1815,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134af885d758d645f0f0505c9a8b3f9bf8a348fd822e112ab5248138348f1722" +checksum = "83f0c8e7c0addab50b663055baf787d0af7f413a46e6e7fb9559a4e4db7137a5" dependencies = [ "autocfg", "bytes 1.0.1", @@ -1847,7 +1847,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" dependencies = [ "native-tls", - "tokio 1.4.0", + "tokio 1.5.0", ] [[package]] @@ -1870,7 +1870,7 @@ dependencies = [ "log", "native-tls", "pin-project", - "tokio 1.4.0", + "tokio 1.5.0", "tokio-native-tls", "tungstenite", ] @@ -1891,16 +1891,16 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5143d049e85af7fbc36f5454d990e62c2df705b3589f123b71f441b6b59f443f" +checksum = "940a12c99365c31ea8dd9ba04ec1be183ffe4920102bb7122c2f515437601e8e" dependencies = [ "bytes 1.0.1", "futures-core", "futures-sink", "log", "pin-project-lite 0.2.6", - "tokio 1.4.0", + "tokio 1.5.0", ] [[package]] @@ -2056,9 +2056,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" dependencies = [ "matches", ] diff --git a/Cargo.toml b/Cargo.toml index 5af26c8..ae713d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "alpaca-data-relay" -version = "0.3.0" +version = "1.0.0" authors = ["Sebastian Rollen "] edition = "2018" From 23fd8d3fd6b474ca9531917edd2b27b1d9a154d3 Mon Sep 17 00:00:00 2001 From: Sebastian Rollen Date: Wed, 14 Apr 2021 16:01:12 -0400 Subject: [PATCH 2/2] remove deployment.yml --- deployment.yml | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 deployment.yml diff --git a/deployment.yml b/deployment.yml deleted file mode 100644 index f345c54..0000000 --- a/deployment.yml +++ /dev/null @@ -1,40 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: alpaca-data-relay-cm -data: - KAFKA__BOOTSTRAP_SERVERS: pkc-ep9mm.us-east-2.aws.confluent.cloud:9092 - KAFKA__GROUP_ID: alpaca-data-relay - KAFKA__SECURITY_PROTOCOL: SASL_SSL - ALPACA__STREAMING_URL: wss://paper-api.alpaca.markets/stream - ALPACA__ACCOUNT_UPDATES: "true" - ALPACA__TRADE_UPDATES: "true" - RUST_LOG: debug - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: alpaca-data-relay-deployment -spec: - selector: - matchLabels: - app: alpaca-data-relay - replicas: 1 - template: - metadata: - labels: - app: alpaca-data-relay - spec: - containers: - - name: alpaca-data-relay - image: 799439856592.dkr.ecr.us-east-1.amazonaws.com/alpaca-data-relay:${IMAGE_TAG} - envFrom: - - configMapRef: - name: alpaca-data-relay-cm - - configMapRef: - name: kafka-config-map - - secretRef: - name: kafka - - secretRef: - name: alpaca