codeql: added setup for NixOS #76
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: tests | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| YT_API_KEY: ${{ secrets.YT_API_KEY }} | |
| TWITCH_SECRET: ${{ secrets.TWITCH_SECRET }} | |
| TWITCH_CLIENT_ID: ${{ secrets.TWITCH_CLIENT_ID }} | |
| jobs: | |
| check-secret: | |
| permissions: | |
| contents: read | |
| runs-on: [ self-hosted, nixos, vod2pod ] | |
| outputs: | |
| has_secrets: ${{ steps.my-key-check.outputs.defined }} | |
| steps: | |
| - name: Check for Secret availability | |
| id: my-key-check | |
| shell: bash | |
| run: | | |
| if [ "${{ secrets.TWITCH_CLIENT_ID }}" != '' ]; then | |
| echo "defined=true" >> $GITHUB_OUTPUT; | |
| else | |
| echo "defined=false" >> $GITHUB_OUTPUT; | |
| fi | |
| build: | |
| permissions: | |
| contents: read | |
| runs-on: [ self-hosted, nixos, vod2pod ] | |
| needs: [check-secret] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build | |
| run: nix develop -c cargo build --verbose | |
| shell: bash | |
| - name: Start Redis server | |
| run: | | |
| nix shell nixpkgs#redis -c redis-server --daemonize yes | |
| shell: bash | |
| - name: Run tests with secrets | |
| run: nix develop -c cargo test --verbose | |
| shell: bash | |
| if: needs.check-secret.outputs.has_secrets == 'true' | |
| - name: Run tests without secrets | |
| run: nix develop -c cargo test --verbose -- --skip requires_api_key | |
| shell: bash | |
| if: needs.check-secret.outputs.has_secrets == 'false' |