You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
3.9 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. # Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md
  2. #
  3. # While our "example" application has the platform-specific code,
  4. # for simplicity we are compiling and testing everything on the Ubuntu environment only.
  5. # For multi-OS testing see the `cross.yml` workflow.
  6. on: [push, pull_request]
  7. name: Continuous Integration
  8. jobs:
  9. check:
  10. name: Check
  11. runs-on: ubuntu-latest
  12. steps:
  13. - name: Checkout sources
  14. uses: actions/checkout@v2
  15. - name: Install stable toolchain
  16. uses: actions-rs/toolchain@v1
  17. with:
  18. profile: minimal
  19. toolchain: stable
  20. override: true
  21. - name: Rust Cache
  22. uses: Swatinem/rust-cache@v1.2.0
  23. - name: Run cargo check
  24. uses: actions-rs/cargo@v1
  25. with:
  26. command: check
  27. test:
  28. name: Test Suite
  29. runs-on: ubuntu-latest
  30. steps:
  31. - name: Checkout sources
  32. uses: actions/checkout@v2
  33. - name: Install stable toolchain
  34. uses: actions-rs/toolchain@v1
  35. with:
  36. profile: minimal
  37. toolchain: stable
  38. override: true
  39. - name: Rust Cache
  40. uses: Swatinem/rust-cache@v1.2.0
  41. - name: Run cargo test
  42. uses: actions-rs/cargo@v1
  43. with:
  44. command: test
  45. lints:
  46. name: Lints
  47. runs-on: ubuntu-latest
  48. steps:
  49. - name: Checkout sources
  50. uses: actions/checkout@v2
  51. - name: Install stable toolchain
  52. uses: actions-rs/toolchain@v1
  53. with:
  54. profile: minimal
  55. toolchain: stable
  56. override: true
  57. components: rustfmt, clippy
  58. - name: Rust Cache
  59. uses: Swatinem/rust-cache@v1.2.0
  60. - name: Run cargo fmt
  61. uses: actions-rs/cargo@v1
  62. with:
  63. command: fmt
  64. args: --all -- --check
  65. - name: Run cargo clippy
  66. uses: actions-rs/cargo@v1
  67. # continue-on-error: true
  68. with:
  69. command: clippy
  70. args: -- -D warnings
  71. build:
  72. name: Build Binaries
  73. if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
  74. runs-on: ubuntu-latest
  75. needs: [check, test, lints]
  76. strategy:
  77. matrix:
  78. target:
  79. - x86_64-unknown-linux-gnu
  80. - aarch64-unknown-linux-gnu
  81. # - powerpc64-unknown-linux-gnu
  82. steps:
  83. - uses: actions/checkout@v2
  84. - uses: actions-rs/toolchain@v1
  85. with:
  86. toolchain: stable
  87. target: ${{ matrix.target }}
  88. override: true
  89. - uses: actions/cache@v2
  90. with:
  91. path: |
  92. ~/.cargo/registry
  93. ~/.cargo/git
  94. target
  95. key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
  96. # - name: Rust Cache
  97. # uses: Swatinem/rust-cache@v1.2.0
  98. # - name: Install PowerPC GCC
  99. # if: matrix.target == 'powerpc64-unknown-linux-gnu'
  100. # run: |
  101. # sudo apt-get install -y gcc-powerpc-linux-gnu
  102. - name: Compile
  103. uses: actions-rs/cargo@v1
  104. with:
  105. use-cross: true
  106. command: build
  107. args: --release --target=${{ matrix.target }}
  108. publish-docker:
  109. name: Build and Publish Docker Image
  110. if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
  111. runs-on: ubuntu-latest
  112. needs: [check, test, lints]
  113. steps:
  114. - uses: actions/checkout@v2
  115. - name: Docker layer cache
  116. uses: satackey/action-docker-layer-caching@v0.0.11
  117. continue-on-error: true
  118. - name: Login to Docker Hub
  119. uses: docker/login-action@v1
  120. with:
  121. username: rohansircar
  122. password: ${{ secrets.DOCKER_LOGIN_PASSWORD }}
  123. - name: Build Image
  124. run: docker build -t rohansircar/actix-demo:latest .
  125. - name: Publish Image
  126. run: docker push rohansircar/actix-demo:latest