716 dissociate the encryption key from the api keys of the master password #1499
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Testing | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - "api/**" | |
| workflow_call: # Add this to make the workflow reusable | |
| workflow_dispatch: # Add this to allow manual triggering | |
| jobs: | |
| unit-tests: | |
| name: Unit tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref || github.ref_name }} | |
| - name: Set up Docker Compose | |
| run: | | |
| cp config.example.yml config.yml | |
| - name: Run unit tests with coverage and publish unit badge | |
| run: | | |
| # Install uv | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.local/bin" >> $GITHUB_PATH | |
| # Create a local virtual environment and install dependencies | |
| "$HOME/.local/bin/uv" venv | |
| "$HOME/.local/bin/uv" pip install -p .venv/bin/python ".[api,playground,dev,test]" | |
| # Activate venv for the test run | |
| . .venv/bin/activate | |
| # Run unit tests with coverage | |
| make test-unit | |
| # Export coverage data to XML for badge computation | |
| python -m coverage xml -o coverage.xml | |
| # Build unit coverage badge JSON | |
| mkdir -p .github/badges | |
| COVERAGE=$(python -c "import xml.etree.ElementTree as ET; print(ET.parse('coverage.xml').getroot().get('line-rate'))") | |
| COVERAGE_PCT=$(printf "%.2f" $(echo "${COVERAGE} * 100" | bc)) | |
| echo "{\"schemaVersion\":1,\"label\":\"coverage\",\"message\":\"${COVERAGE_PCT}%\",\"color\":\"$(if (( $(echo \"${COVERAGE_PCT} >= 80\" | bc -l) )); then echo "green"; elif (( $(echo \"${COVERAGE_PCT} >= 70\" | bc -l) )); then echo "yellow"; else echo "red"; fi)\"}" > .github/badges/coverage.json | |
| - name: Commit unit coverage badge | |
| if: github.event.pull_request.base.ref == 'main' | |
| uses: stefanzweifel/git-auto-commit-action@v4 | |
| with: | |
| commit_message: Update unit coverage badge | |
| file_pattern: .github/badges/coverage.json | |
| commit_user_name: "GitHub Actions" | |
| commit_user_email: "actions@github.com" | |
| integration-tests: | |
| name: Integration tests | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| config_file: [api/tests/integ/config.test.yml] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run integration tests | |
| run: | | |
| cp .github/.env.ci.example .github/.env.ci | |
| # Install uv | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.local/bin" >> $GITHUB_PATH | |
| # Create a local virtual environment and install dependencies | |
| "$HOME/.local/bin/uv" venv | |
| "$HOME/.local/bin/uv" pip install -p .venv/bin/python ".[api,playground,dev,test]" | |
| # Activate venv for the test run | |
| . .venv/bin/activate | |
| echo "Listing files in root:" | |
| ls -la . | |
| echo "Listing files in api/tests/integ:" | |
| ls -la api/tests/integ | |
| # Run integration tests | |
| make test-integ | |
| env: | |
| CONFIG_FILE: ${{ matrix.config_file }} | |
| ALBERT_API_KEY: ${{ secrets.ALBERT_API_KEY }} |