投稿時間:2023-07-02 13:04:34 RSSフィード2023-07-02 13:00 分まとめ(5件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT ITmedia 総合記事一覧 [ITmedia News] Twitterの混乱にジャック・ドーシー氏が「みんな落ち着いて」「批判するのは簡単だが」とツイート https://www.itmedia.co.jp/news/articles/2307/02/news043.html itmedianewstwitter 2023-07-02 12:28:00
IT ITmedia 総合記事一覧 [ITmedia News] 「FF16」速攻クリアした漫画家が「面白い、けど……」とボヤき続けた理由 https://www.itmedia.co.jp/news/articles/2307/02/news040.html finalfantasyxvi 2023-07-02 12:15:00
python Pythonタグが付けられた新着投稿 - Qiita ChatGPT plugin 「chat with workspace」からChromeブックマークを探索する ~notionを介して~ https://qiita.com/kzuzuo/items/ee6d7a2621076df70595 chrome 2023-07-02 12:42:57
Docker dockerタグが付けられた新着投稿 - Qiita IX2215のメトリクスをPrometheus+Grafanaで監視する【Docker】 https://qiita.com/rokuosan/items/c974c27f7134a778564f docker 2023-07-02 12:33:52
海外TECH DEV Community Mastering Django CI/CD using GitHub Actions https://dev.to/devvspaces/mastering-django-cicd-using-github-actions-2912 Mastering Django CI CD using GitHub ActionsTesting and delivery is a common repetitive cycle in application development This cycle consumes more time and resources as we fix or add more features to our application Automating this repetitive process will reduce the time spent in application development Testing and Deployment are part of the cycle discussed earlier We build deploy and test our applications a lot Doing this every time is vulnerable to human error Automating our tests guarantees that every commit undergoes testing This article covers how we can use GitHub Actions to automatically test our Django applications Let s dive in PrerequisitesTo follow through with this article we need the following Basic knowledge of Django Git and GitHubA GitHub accountPython and Django installed on our operating system Setup Demo Django ApplicationWe need a Django application that has tests to understand how GitHub actions work We can work with this demo Django project which includes tests GitHub actions run on GitHub repositories and not on our machines Only the owner of the repository can manage workflow runs Later in the article we will cover what Workflows are We need to fork the repository and clone it git clone lt REPOSITORY URL gt We should set up a new virtual environment linux and maccd lt PROJECT DIR gt python m venv venvsource venv bin activate windowscd lt PROJECT DIR gt python m venv venvvenv Scripts activate lt differenceNow we need to install the project dependencies Run this command in the project directory This will install all the dependencies specified in requirements txt file pip install r requirements txtNow that our application setup is complete Let s run our tests will The tests confirm the reliability of our application cd projectpython manage py testThe tests are successful We can now go ahead and automate this process using GitHub actions Automated tests don t only work when we use Django s built in test runners We can write automation for any kind of test runners we are using One popular test runner in the Python community is Pytest What are GitHub Actions To get started we need to define a workflow A workflow is a configurable automated process that will run one or more jobs A step is a command or action that performs a basic task An Action is a collection of steps which makes an action reusable A Job is an operation in a workflow that contains steps Jobs can run in parallel or in sequence We define workflows by using a YAML file checked in the repository A workflow will execute when triggered by an event in the same repository it exists GitHub workflows listen to many events examples are push and pull requests The events configured into our YAML file trigger our workflow For example when we push a new commit to the master branch this can trigger a testing workflow Creating A Testing WorkflowLet s create a workflow that executes our Django application tests Workflows are not for testing but for executing jobs which can be anything An example of this is running tests Our tests are already defined We configure workflows to execute them Other use cases are deployments and closing pull requests Create a new directory called github workflows in the root directory Create a new file called test yml in the github workflows directory This file will be our workflow YAML configuration test ymlname Run Django Testson push branches master jobs test django app runs on ubuntu latest strategy fail fast false matrix python version steps uses actions checkout v with fetch depth name Set up Python matrix python version uses actions setup python v with python version matrix python version name Install dependencies run python m pip install upgrade pip if f requirements txt then pip install r requirements txt fi name Run Django test run cd project python manage py testLet s break down what each syntax means and how this executes the application tests We start by defining the workflow name by using the name syntax name Run Django TestsThe workflow name helps us identify the workflow in our repository s GitHub Actions tab The GitHub Actions tab helps us to manage workflow runs See how to manage a workflow run on GitHub Next we define the event that triggers the workflow on push branches master By using the on syntax every commit we push to the master branch triggers the workflow run We can specify many events and branches Next we have the jobs syntax jobs test django app A scenario to use this is when we want to deploy a web application after successful tests We can create two jobs one for testing and the other for deployment Then configure the deployment to run after when tests are complete and successful The name of our job is test django app we can name it anything But make sure it s descriptive as it helps us identify the currently running job in the GitHub Actions tab Next the runs on syntax defines what machine will run the job Here we instructed it to use ubuntu latest version runs on ubuntu latestNext the strategy syntax helps us define what Python versions we will use to test In our workflow we have defined only one version The job will use each Python version declared in the list to execute itself in parallel strategy fail fast false matrix python version fail fast applies to the entire matrix If fail fast is set to true GitHub will cancel all in progress and queued jobs in the matrix if any job in the matrix fails This property defaults to true Assuming that we built a Python package and set many Python versions We can ensure the package undergoes testing across defined Python versions Jobs contain a sequence of tasks called steps Steps can run commands set up docker or run an action in our repository These steps run one after the other based on their position in the YAML definition The following are the actions taken by each step in our workflow Checkout the repository on the machine defined for the job Setup Python using the current version from the strategy Install pip and the project dependencies Move into the project directory and run the tests We need to commit and push a new workflow to trigger our workflow git add git commit m Added tests automation using Github Actions git pushWe should see a new running or completed workflow run on the GitHub actions tab in our forked repository This workflow would show us each job and the steps executed GitHub workflow job management tab Now any time we push a new commit to the master branch Our workflow executes our Django application tests Understanding GitHub Actions is a complete guide to learning actions workflows and jobs Check it out to master project development automation ConclusionIn this article we have covered how GitHub actions execute Django application tests Continuous Integration and Delivery is an important part of a modern development cycle Automating development life cycles ensures we build reliable applications when working with collaborators ResourcesUnderstanding GitHub Actions by GitHubIntroduction to GitHub Actions Training by MicrosoftGitHub Actions Tutorial for Beginners to Automate Your Workflow 2023-07-02 03:23:10

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)