sommerfeld-io / source2adoc

Streamline the process of generating AsciiDoc documentation from inline comments within source code files. This tool converts inline documentation into AsciiDoc files, tailored for seamless integration with Antora.
https://source2adoc.sommerfeld.io
Other
0 stars 0 forks source link

Run Inspec tests on devcontainer from pipeline (linux-baseline + custom) #56

Open sebastian-sommerfeld-io opened 4 months ago

sebastian-sommerfeld-io commented 4 months ago

RELATES TO


todo

Run inspec tests against the dev container ...

:question:

components/test/compliance/inspec/devcontainer-profile/controls/decvontainer-checks.rb

##
#
##

title 'devcontainer checks'

control 'devcontainer-1.0' do
    impact 0.5
    title 'Verify devcontainer operating system'
    desc 'Verify the devcontainer operating system type and configuration'

    describe os.family do
        it { should eq 'debian' }
    end
end

control 'devcontainer-1.1' do
    impact 0.5
    title 'Verify user "vscode" presence and configuration'
    desc 'Verify that the user "vscode" is present and correctly configured'

    describe user('vscode') do
        it { should exist }
        its('home') { should eq '/home/vscode' }
        its('shell') { should eq '/bin/bash' }
    end
end

control 'devcontainer-1.2' do
    impact 0.5
    title 'Verify source2adoc directory'
    desc 'Verify that the source2adoc directory exists and has the correct ownership'
    describe directory('/workspaces/source2adoc') do
        it { should exist }
        it { should be_directory }
        its('owner') { should eq 'vscode' }
        its('group') { should eq 'vscode' }
    end
end

.github/workflows/pipeline.yml

  inspec-devcontainer:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Validate devcontainer profile
        run: |
          docker run --rm \
            --volume ./components/test/compliance/inspec:/inspec \
            --workdir /inspec \
            chef/inspec:latest check devcontainer-profile --chef-license=accept-no-persist
        shell: bash
      - name: Run devcontainer profile
        run: |
            docker run --rm \
            --volume ./components/test/compliance/inspec:/inspec \
            --volume /workspaces:/workspaces \
            --workdir /inspec \
            --user $(id -u):$(id -g) \
            chef/inspec:latest exec devcontainer-profile --chef-license=accept-no-persist
        shell: bash