diff --git a/.github/actions/lint-it/action.yml b/.github/actions/lint-it/action.yml index f3f50aa..fb4c538 100644 --- a/.github/actions/lint-it/action.yml +++ b/.github/actions/lint-it/action.yml @@ -6,15 +6,17 @@ runs: steps: - name: Create venv. run: | - python3 -m venv --clear venv + pushd $HOME + python3 -m venv --clear .venv-linter + popd shell: bash - name: Install dependencies run: | - ./venv/bin/python3 -m pip install -U setuptools pip - ./venv/bin/python3 -m pip install -e .[dev] + "$HOME/.venv-linter/bin/python" -m pip install -U setuptools pip + "$HOME/.venv-linter/bin/python" -m pip install -e .[dev] shell: bash - name: Test with pytest run: | - ./venv/bin/python3 -m py.test -m "linter" --lint-code + "$HOME/.venv-linter/bin/python" -m py.test -m "linter" --lint-code shell: bash diff --git a/.github/actions/pip-freeze-v2/action.yml b/.github/actions/pip-freeze-v2/action.yml deleted file mode 100644 index ebd879b..0000000 --- a/.github/actions/pip-freeze-v2/action.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: 'Generate pip freeze file.' - -runs: - using: "composite" - steps: - - run: | - ./venv/bin/python -m pip freeze > requirements.txt - shell: bash diff --git a/.github/actions/pip-freeze/action.yml b/.github/actions/pip-freeze/action.yml deleted file mode 100644 index f2af358..0000000 --- a/.github/actions/pip-freeze/action.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: 'Generate pip freeze file.' - -runs: - using: "composite" - steps: - - run: | - ./venv/bin/python3 -m pip freeze > requirements.txt - shell: bash diff --git a/.github/actions/test-it-v2/action.yml b/.github/actions/test-it-v2/action.yml deleted file mode 100644 index 02f38a9..0000000 --- a/.github/actions/test-it-v2/action.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: 'Test it on Python2.7!' -description: 'Test this repo.' - -runs: - using: "composite" - steps: - - name: Install virtualenv. - run: | - sudo apt update - sudo apt install -y virtualenv python-pip - shell: bash - - name: Create venv. - run: | - virtualenv -p python2.7 --clear venv - shell: bash - - name: Install dependencies - run: | - ./venv/bin/python2.7 -m pip install -U setuptools pip - ./venv/bin/python2.7 -m pip install -U 'ansible<2.0.0' - ./venv/bin/python2.7 -m pip install -e .[dev] - shell: bash - - name: Test with pytest - run: | - ./venv/bin/python2.7 -m py.test - shell: bash diff --git a/.github/actions/test-it/action.yml b/.github/actions/test-it/action.yml index 6084464..db8efba 100644 --- a/.github/actions/test-it/action.yml +++ b/.github/actions/test-it/action.yml @@ -1,21 +1,47 @@ name: 'Test it!' description: 'Test this repo.' +inputs: + python-version: + required: true + runs: using: "composite" steps: - - name: Create venv. - run: | - python3 -m venv --clear venv + - name: Setup test env. + run: |- + my_venv_bin="$HOME/.venv${{inputs.python-version}}/bin/python" + + sudo apt-get update -y + sudo apt-get install -y python-pip-whl python3-venv + + if [[ "${{inputs.python-version}}" == "2.7" ]] ; then + python2.7 -m pip install --user -U setuptools pip + python2.7 -m pip install --user -U virtualenv + pushd $HOME + $HOME/.local/bin/virtualenv -p python2.7 --clear --no-wheel .venv2.7 + popd + else + pushd $HOME + python${{inputs.python-version}} -m venv --clear .venv${{inputs.python-version}} + popd + fi + + "$my_venv_bin" -m pip install -U setuptools pip + if [[ "${{inputs.python-version}}" == "2.7" ]] ; then + "$my_venv_bin" -m pip install -U 'ansible<2.0.0' + elif [[ "${{inputs.python-version}}" == "3.5" ]] ; then + "$my_venv_bin" -m pip install -U 'cryptography==3.2.1' + fi + "$my_venv_bin" -m pip install -e .[dev] shell: bash - - name: Install dependencies + + - name: Test with pytest run: | - _pyver=$(./venv/bin/python3 -c 'import sys;print("".join(sys.version.split(".")[0:2]))') - ./venv/bin/python3 -m pip install -U setuptools pip - [[ "$_pyver" == "35" ]] && ./venv/bin/python3 -m pip install -U 'cryptography==3.2.1' - ./venv/bin/python3 -m pip install -e .[dev] + "$HOME/.venv${{inputs.python-version}}/bin/python" -m py.test -m "not linter" shell: bash - - name: Test with pytest + + - name: Output req.txt for cache run: | - ./venv/bin/python3 -m py.test -m "not linter" + "$HOME/.venv${{inputs.python-version}}/bin/python" -m pip freeze > requirements.txt shell: bash diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index cd0daed..0663564 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -14,7 +14,7 @@ name: "CodeQL" on: push: branches: [ master ] - pull_request: + pull_request_target: # The branches below must be a subset of the branches above branches: [ master ] schedule: diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index 3997483..0000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: linter - -on: - push: - branches: [ "*" ] - pull_request: - branches: [ "master" ] - schedule: - - cron: '15 6 * * *' - -jobs: - unittest: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ansible-vault-${{ runner.os }}-${{ hashFiles('**/requirements.txt') }} - restore-keys: ansible-vault-${{ runner.os }}- - - uses: actions/setup-python@v2 - with: - python-version: "3.9" - - uses: tomoh1r/ansible-vault/.github/actions/lint-it@master diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml index d725c20..e9dcd07 100644 --- a/.github/workflows/super-linter.yml +++ b/.github/workflows/super-linter.yml @@ -2,8 +2,8 @@ name: super-linter on: push: - branches: [ "*" ] - pull_request: + branches: [ "master" ] + pull_request_target: branches: [ "master" ] jobs: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7662a97..c647e72 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,12 +3,26 @@ name: test on: push: branches: [ "*" ] - pull_request: + pull_request_target: branches: [ "master" ] schedule: - cron: '30 6 * * *' jobs: + code-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ansible-vault-${{ runner.os }}-${{ hashFiles('**/requirements.txt') }} + restore-keys: ansible-vault-${{ runner.os }}- + - uses: actions/setup-python@v2 + with: + python-version: "3.9" + - uses: ./.github/actions/lint-it + unittest: runs-on: ubuntu-latest strategy: @@ -24,11 +38,6 @@ jobs: - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - uses: tomoh1r/ansible-vault/.github/actions/test-it@master - if: "matrix.python-version != '2.7'" - - uses: tomoh1r/ansible-vault/.github/actions/test-it-v2@master - if: "matrix.python-version == '2.7'" - - uses: tomoh1r/ansible-vault/.github/actions/pip-freeze@master - if: "matrix.python-version != '2.7'" - - uses: tomoh1r/ansible-vault/.github/actions/pip-freeze-v2@master - if: "matrix.python-version == '2.7'" + - uses: ./.github/actions/test-it + with: + python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/wiki.yml b/.github/workflows/wiki.yml index bf186bf..c09d568 100644 --- a/.github/workflows/wiki.yml +++ b/.github/workflows/wiki.yml @@ -1,6 +1,10 @@ name: wiki -on: push +on: + push: + branches: [ "master" ] + pull_request_target: + branches: [ "master" ] jobs: build: