1
0

lint.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. name: Lint
  2. on: [push, pull_request]
  3. jobs:
  4. Salt:
  5. name: Lint Salt's Source Code
  6. runs-on: ubuntu-latest
  7. container:
  8. image: python:3.8.6-slim-buster
  9. steps:
  10. - name: Install System Deps
  11. run: |
  12. apt-get update
  13. apt-get install -y enchant git gcc make zlib1g-dev libc-dev libffi-dev g++ libxml2 libxml2-dev libxslt-dev libcurl4-openssl-dev libssl-dev libgnutls28-dev
  14. - uses: actions/checkout@v2
  15. - name: Set Python Version Env Var
  16. run: |
  17. echo PY_VERSION=$(python -c 'import sys; print("{}.{}".format(*sys.version_info))') >> $GITHUB_ENV
  18. - name: Install Nox
  19. run: |
  20. python -m pip install --upgrade pip
  21. pip install nox
  22. - name: Set Lint Python Cache Key
  23. run: echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
  24. - name: Setup Nox Cache
  25. uses: pat-s/always-upload-cache@v2.1.3
  26. with:
  27. path: .nox/
  28. key: lint-salt|${{ env.PY }}|${{ hashFiles(format('requirements/static/ci/py{0}/*.txt', env.PY_VERSION)) }}
  29. - id: changed-files
  30. name: Get Changed Files
  31. uses: dorny/paths-filter@v2
  32. with:
  33. token: ${{ github.token }}
  34. list-files: json
  35. filters: |
  36. salt:
  37. - added|modified:
  38. - setup.py
  39. - noxfile.py
  40. - salt/**/*.py
  41. - tasks/**/*.py
  42. - name: Install Python Requirements
  43. env:
  44. PIP_EXTRA_INDEX_URL: https://artifactory.saltstack.net/artifactory/api/pypi/pypi-open/simple/
  45. run:
  46. nox --install-only --forcecolor -e lint-salt
  47. - name: Lint Changed Files
  48. if: github.event_name == 'pull_request' && steps.changed-files.outputs.salt == 'true'
  49. env:
  50. SKIP_REQUIREMENTS_INSTALL: YES
  51. run: |
  52. nox --forcecolor -e lint-salt -- ${{ join(fromJSON(steps.changed-files.outputs.salt_files), ' ') }}
  53. - name: Lint ALL Files
  54. if: steps.changed-files.outputs.salt == 'true'
  55. env:
  56. SKIP_REQUIREMENTS_INSTALL: YES
  57. run: |
  58. nox --forcecolor -e lint-salt
  59. Tests:
  60. name: Lint Salt's Test Suite
  61. runs-on: ubuntu-latest
  62. container:
  63. image: python:3.8.6-slim-buster
  64. steps:
  65. - name: Install System Deps
  66. run: |
  67. apt-get update
  68. apt-get install -y enchant git gcc make zlib1g-dev libc-dev libffi-dev g++ libxml2 libxml2-dev libxslt-dev libcurl4-openssl-dev libssl-dev libgnutls28-dev
  69. - uses: actions/checkout@v2
  70. - name: Set Python Version Env Var
  71. run: |
  72. echo PY_VERSION=$(python -c 'import sys; print("{}.{}".format(*sys.version_info))') >> $GITHUB_ENV
  73. - name: Install Nox
  74. run: |
  75. python -m pip install --upgrade pip
  76. pip install nox
  77. - name: Set Lint Python Cache Key
  78. run: echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
  79. - name: Setup Nox Cache
  80. uses: pat-s/always-upload-cache@v2.1.3
  81. with:
  82. path: .nox/
  83. key: lint-tests|${{ env.PY }}|${{ hashFiles(format('requirements/static/ci/py{0}/*.txt', env.PY_VERSION)) }}
  84. - id: changed-files
  85. name: Get Changed Files
  86. uses: dorny/paths-filter@v2
  87. with:
  88. token: ${{ github.token }}
  89. list-files: json
  90. filters: |
  91. tests:
  92. - added|modified:
  93. - tests/**/*.py
  94. - name: Install Python Requirements
  95. env:
  96. PIP_EXTRA_INDEX_URL: https://artifactory.saltstack.net/artifactory/api/pypi/pypi-open/simple/
  97. run:
  98. nox --install-only --forcecolor -e lint-tests
  99. - name: Lint Changed Files
  100. if: github.event_name == 'pull_request' && steps.changed-files.outputs.tests == 'true'
  101. env:
  102. SKIP_REQUIREMENTS_INSTALL: YES
  103. run: |
  104. nox --forcecolor -e lint-tests -- ${{ join(fromJSON(steps.changed-files.outputs.tests_files), ' ') }}
  105. - name: Lint ALL Files
  106. if: steps.changed-files.outputs.tests == 'true'
  107. env:
  108. SKIP_REQUIREMENTS_INSTALL: YES
  109. run: |
  110. nox --forcecolor -e lint-tests