diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 00000000..1c355db8 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,28 @@ +name: Setup +description: Set up Baby Buddy environment and dependencies. +inputs: + python-version: + description: 'What Python version to use.' + required: false + default: '3.x' +runs: + using: 'composite' + steps: + - uses: actions/setup-python@v3 + id: setup-python + with: + python-version: ${{ inputs.python-version }} + - uses: actions/cache@v3 + with: + path: | + ~/.local/share/virtualenvs + Pipfile.lock + key: ${{ runner.os }}-python-${{ inputs.python-version }}-pipenv-${{ hashFiles('**/requirements.txt') }} + - name: Install Python dependencies + shell: bash + run: | + python -m pip install --upgrade pipenv wheel + pipenv install --dev + - uses: actions/setup-node@v3 + with: + node-version: 16 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b27f9f13..d85b5656 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,23 +14,9 @@ jobs: python-version: [ '3.7', '3.8', '3.9', '3.10' ] steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - id: setup-python + - uses: ./.github/actions/setup with: python-version: ${{ matrix.python-version }} - - uses: actions/cache@v3 - with: - path: | - ~/.local/share/virtualenvs - Pipfile.lock - key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('**/requirements.txt') }} - - name: Install Python dependencies - run: | - python -m pip install --upgrade pipenv wheel - pipenv install --dev - - uses: actions/setup-node@v3 - with: - node-version: 16 - run: | npm install -g gulp-cli npm install @@ -74,6 +60,9 @@ jobs: if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} steps: - uses: actions/checkout@v3 + - uses: ./.github/actions/setup + - name: Install Railway CLI + run: npm i -g @railway/cli - name: Deploy demo run: npx railway up env: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3d232a44..0a3257b7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -20,23 +20,10 @@ jobs: language: [ 'javascript', 'python' ] steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - id: setup-python - with: - python-version: '3.x' - - uses: actions/cache@v3 - with: - path: | - ~/.local/share/virtualenvs - Pipfile.lock - key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('**/requirements.txt') }} - uses: github/codeql-action/init@v2 with: config-file: ./.github/codeql/codeql-config.yml languages: ${{ matrix.language }} setup-python-dependencies: false - - name: Install dependencies - run: | - python -m pip install --upgrade pipenv wheel - pipenv install + - uses: ./.github/actions/setup - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/demo-reset.yml b/.github/workflows/demo-reset.yml index e01292e3..eaad949c 100644 --- a/.github/workflows/demo-reset.yml +++ b/.github/workflows/demo-reset.yml @@ -12,23 +12,7 @@ jobs: url: https://demo.baby-buddy.net steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - id: setup-python - with: - python-version: '3.x' - - uses: actions/cache@v3 - with: - path: | - ~/.local/share/virtualenvs - Pipfile.lock - key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('**/requirements.txt') }} - - name: Install pipenv - run: python -m pip install --upgrade pipenv wheel - - name: Install dependencies - run: pipenv install - - uses: actions/setup-node@v3 - with: - node-version: '16' + - uses: ./.github/actions/setup - name: Install Railway CLI run: npm i -g @railway/cli - name: Reset demo database