Skip to content

Commit

Permalink
DevContainer and automatic versioning (henne49#158)
Browse files Browse the repository at this point in the history
* add initial files
* Fix typo in Dockerfile
* Add GitVersion
* Add version file
* Update Dockerfile to optimize image layers and install GitVersion.Tool
* Add GitVersion.yml configuration file
* Add codeql workflow and dependencies
  • Loading branch information
0x7878 committed Apr 17, 2024
1 parent b94dc8f commit 3e59590
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 54 deletions.
18 changes: 18 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM mcr.microsoft.com/vscode/devcontainers/python:3
RUN pip install requests

# Switch to the vscode user
USER vscode

WORKDIR /home/vscode

# Update and install dependencies in a single RUN command to reduce image layers
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && \
chmod +x ./dotnet-install.sh && \
./dotnet-install.sh --version latest && \
rm dotnet-install.sh

# Install GitVersion
RUN /home/vscode/.dotnet/dotnet tool install --global GitVersion.Tool --version 5.* && \
echo 'export DOTNET_ROOT=$HOME/.dotnet' >> ~/.bashrc && \
echo 'export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools' >> ~/.bashrc
13 changes: 13 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Python Dev Container",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"docker-in-docker": {
"version": "latest",
"moby": true,
"dockerDashComposeVersion": "v1"
}
}
}
68 changes: 16 additions & 52 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
branches: ["main"]
schedule:
- cron: '19 16 * * 2'
- cron: "19 16 * * 2"

jobs:
analyze:
Expand All @@ -32,45 +20,21 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
language: ["python"]

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@v2


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
51 changes: 51 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "Update Version"

on:
push:
# tags:
# - v*
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["main"]
workflow_dispatch:
jobs:
versioning:
name: Versioning
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: setup .net core
uses: actions/setup-dotnet@v1
with:
dotnet-version: "8.0.x"

- name: install gitversion
uses: gittools/actions/gitversion/setup@v0
with:
versionspec: "5.x"

- name: Use GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v0

- name: Create version file
run: |
echo "Version: ${{ steps.gitversion.outputs.majorMinorPatch }}" > version.txt
- name: Commit and push
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add version.txt
git commit -m "Update version"
git push
5 changes: 5 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mode: Mainline
branches: {}
ignore:
sha: []
merge-message-formats: {}
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


# dbus-opendtu

> **Attention:**
Expand Down
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Version: 1.1.20

0 comments on commit 3e59590

Please sign in to comment.